# gbit **Repository Path**: yafengli/gbit ## Basic Information - **Project Name**: gbit - **Description**: golang library. - **Primary Language**: Go - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-04-14 - **Last Updated**: 2025-07-16 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # GBIT-COMMON ### glog ```go // 导入 import log "gitee.com/yafengli/gbit/glog" // 初始化 log.InitLog(log.InfoLevel, "/Users/yafengli/tmp/demo.log", 2, 2, 2) // 日志输出 log.Info("hello world") ``` ## os ```go ost := runtime.GOOS // linux command := "ps ax | grep java" // windows if strings.EqualFold(ost, "windows") { command = "dir d:\\Tmp" } // 执行系统命令 err, o, e := os.Exec(command) if err != nil { log.Fatal(err) } fmt.Println("--- stdout ---") fmt.Println(o) fmt.Println("--- stderr ---") fmt.Println(e) ``` ## tcpsend ```go func Demo() { addr := "192.168.0.114:9000" // 开始 & 异步处理接受收消息回复 go ts.Start(addr, func(m string) { fmt.Println("message:", m) }) time.Sleep(2 * time.Second) // 异步发消息 go func() { for i := 0; i < 5; i++ { ts.SendMessages([]string{"nice to meet you!", "what the hell!"}) time.Sleep(1 * time.Second) } }() time.Sleep(10 * time.Second) // 关闭连接 ts.Stop() } ``` ## Test ```shell go test -timeout 30s -v -run ^TestLog$ tests/log_test.go go test -v -run TestExec test/shell_test.go go test -v -run TestPools test/pools_test.go go test -v -run TestTcpSend test/tcpsend_test.go ```