1 Star 0 Fork 0

万古云霄一羽毛 / gbit

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

GBIT-COMMON

os

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

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

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

空文件

简介

golang library. 展开 收起
Go
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Go
1
https://gitee.com/yafengli/gbit.git
git@gitee.com:yafengli/gbit.git
yafengli
gbit
gbit
master

搜索帮助

14c37bed 8189591 565d56ea 8189591