把内容写入多个地方
package main import ( "io" "os" ) func main() { f,_:=os.Create("tmp.txt") defer f.Close() writers := []io.Writer{ f, os.Stdout, } writer := io.MultiWriter(writers...) writer.Write([]byte("把内容写入多个地方")) }