need more detailed usage? please refer test cases.
may be not classfied yet..
After()
- run func after some durationAvailablePort()
- return random available tcp portsAvailableUdpPort()
- return random available udp portsClearBit()
- clear bit postionDoWithWorker()
- run go routine with n worksEvery()
- run goroutine in every durationFileExists()
- return true if file existsFilename()
- return current source file nameIsContextDone()
- return true if context is doneJsonRecode()
- redecode as new typeNewPool()
-sync.Pool
with typeSetBit()
- set bit positionSetNX()
- acts as redis SetNXStrToTime()
- parse standard time format as easyURLToListenAddr()
- parse url and get listenable address, ports
run command and output to stdin/stdout
exc := Exec("ls", "-al")
err := exc.Do(context.Background())
require.NoError(t, err)
run command and get output
exc := Exec("ls", "-al")
output, err := exc.Output(context.Background())
require.NoError(t, err)
require.Contains(t, string(output), "README.md")
IfThen(true, func() { fmt.Printf("true\n") })
// true
IfThen(true, func() { fmt.Printf("true\n") }, func() { fmt.Printf("false\n") })
// true
IfThen(false, func() { fmt.Printf("true\n") }, func() { fmt.Printf("false\n") })
// false
IfThen(false, func() { fmt.Printf("true\n") }, func() { fmt.Printf("false\n") }, func() { fmt.Printf("false\n") })
// false
b := RandomByte(10)
// hex.EncodeToString(b) = "4d46ef2f87b8191daf58"
s := RandomString(10)
// s = "$c&I$#LR3Y"
s := RandomStringWith(10, []rune("abcdefg"))
// s = "bbffedabda"
s := RandomStringWithCrypto(10)
// s = "d0tu0r3)oZ"
func doSomething() {
defer goxp.Timer("doSomething()")()
time.Sleep(500 * time.Millisecond)
}
doSomething()
// time takes 500.505063ms: doSomething()
- cryptox - encrypt/ decrypt functions
- fixtures - useful fixture functions for test
- flags - cobra & viper make easy
- fx - experimental: some functional functions
- httptest - test http sever make easy
- log - simple log powered by zap
- request - simple http client
- retry - retrier with backoff
- service - simple service framework
- slug - uuid to slug
- types - Some useful types
- validator - validator make easy