Skip to content

Instantly share code, notes, and snippets.

@iMega
Created June 1, 2018 09:12
Show Gist options
  • Select an option

  • Save iMega/79de7e52bfdcce87a83e5a69399b9394 to your computer and use it in GitHub Desktop.

Select an option

Save iMega/79de7e52bfdcce87a83e5a69399b9394 to your computer and use it in GitHub Desktop.
Дублирование потоков
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