Created
June 1, 2018 09:12
-
-
Save iMega/79de7e52bfdcce87a83e5a69399b9394 to your computer and use it in GitHub Desktop.
Дублирование потоков
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "bytes" | |
| "io" | |
| "io/ioutil" | |
| "log" | |
| "strings" | |
| ) | |
| func main() { | |
| r := strings.NewReader("io.Reader stream to be read") | |
| var buf bytes.Buffer | |
| tee := io.TeeReader(r, &buf) | |
| teeBuf, _ := ioutil.ReadAll(tee) | |
| bufBuf, _ := ioutil.ReadAll(&buf) | |
| log.Println(string(teeBuf)) | |
| log.Println(string(bufBuf)) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment