go get -u github.com/jarvanstack/go_utils
see the **_test file to learn how to use.
test_util loop time + time cost + ops (QPS)
How to use?
package main
import (
"github.com/jarvanstack/go_utils/test_util"
"testing"
"time"
)
func Test_test_util(t *testing.T) {
tu := test_util.NewTestUtil(1000)
tu.Start()
for i := 0; i < 1000; i++ {
time.Sleep(time.Millisecond)
}
tu.End()
}
throw_util try catch the error can print stack error to help you find where is error happen.
- string_util (1) get random string,(2) md5 ...
expose some unsafe pointer or fd to help you to do syscall call.
import (
"fmt"
"github.com/jarvanstack/go_utils/syscall_util"
"github.com/jarvanstack/go_utils/throw_util"
)
func main() {
var err error
listen, err := sysu.Listen(9999)
erru.Throw(err)
for {
conn, err := listen.Accept()
erru.Throw(err)
go func() {
defer conn.Close()
fmt.Printf("conn.ClientFd=%#v\n", conn.ClientFd)
fmt.Printf("conn.ServerFd=%#v\n", conn.ServerFd)
conn.Write([]byte("hi,syscall_util"))
}()
}
}