1 Star 1 Fork 0

湖底观景/GolangTraining

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
main.go 880 Bytes
一键复制 编辑 原始数据 按行查看 历史
GoesToEleven 提交于 2016-04-20 17:45 . changes dir structure
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.
*/
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhangjianGood/GolangTraining.git
git@gitee.com:zhangjianGood/GolangTraining.git
zhangjianGood
GolangTraining
GolangTraining
afa19f5c43f3

搜索帮助