ogulcanarbc / gommons

Swiss army knife for Golang developers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gommons

Swiss army knife for Golang developers

Features

  • Async tasks
  • Async tasks with results
  • Command exec utils
  • Zero alloc string-byte conversion
  • Time utils
  • Array utils
Async

Async tasks

New().Task(
    func () {
        a = 1
        fmt.Println("1")
    }, func () {
        b = 1
        fmt.Println("2")
    }).Await()

Async tasks with results

results := NewAsyncWorkWithResult[int]().TaskWithResult(
    func() int {
        return 5
    }, func() int {
        return 11
    }).AwaitResult()
Command exec

Run posix command and get output as byte array

out := Exec("echo", "test")

Run posix command with pipes

strReader := strings.NewReader("hello world")

outWriter := bytes.NewBuffer(nil)
errWriter := bytes.NewBuffer(nil)

ExecPipe(strReader, outWriter, errWriter, "echo", "test")
outputStr := outWriter.String()
Zero alloc string byte conversion

String to byte array zero allocation

str := String([]byte("test"))

Byte to string

byteArr := Byte("test")
Time utils

About

Swiss army knife for Golang developers


Languages

Language:Go 100.0%