大佬教程收集整理的这篇文章主要介绍了Golang可以安全地切换cmd.Stdout,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
cmd := exec.Command(path) cmd.Dir = dir t := time.Now() t1 := t.Format("20060102-150405") fs,err := os.Create(dir + "/var/log/" + t1 + ".std") if err == nil { cmd.Stdout = fs }
我希望每天轮换日志并更改日志文件
http://golang.org/pkg/os/exec/
// Stdout and Stderr specify the process's standard output and error. // // If either is nil,Run connects the corresponding file descriptor // to the null device (os.DevNull). // // If Stdout and Stderr are the same writer,at most one // goroutIne at a time will call Write. Stdout io.Writer Stderr io.Writer
从arbitary goroutIne每天更改cmd.Stdout变量是否安全,或者我必须实现将从Stdout复制到另一个文件并切换文件的goroutIne?
以上是大佬教程为你收集整理的Golang可以安全地切换cmd.Stdout全部内容,希望文章能够帮你解决Golang可以安全地切换cmd.Stdout所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。