代码拉取完成,页面将自动刷新
package main
import (
"io"
"os"
)
func main() {
src, err := os.Open("src.txt")
if err != nil {
panic(err)
}
defer src.Close()
dst1, err := os.Create("dst1.txt")
if err != nil {
panic(err)
}
defer dst1.Close()
dst2, err := os.Create("dst2.txt")
if err != nil {
panic(err)
}
defer dst2.Close()
dst3, err := os.Create("dst3.txt")
if err != nil {
panic(err)
}
defer dst3.Close()
rdr := io.TeeReader(src, dst1)
rdr = io.TeeReader(rdr, os.Stdout)
rdr = io.TeeReader(rdr, dst2)
io.Copy(dst3, rdr)
}
/*
func TeeReader(r Reader, w Writer) Reader
TeeReader returns a Reader that writes to w what it reads from r. All reads from r performed through it are matched with corresponding writes to w. There is no internal buffering - the write must complete before the read completes. Any error encountered while writing is reported as a read error.
*/
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。