代码拉取完成,页面将自动刷新
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)
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()
}
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
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。