Commit 5e5a1ed8 authored by Guilherme Rezende's avatar Guilherme Rezende Committed by Joe Tsai

io: add example for Pipe

Change-Id: I24374accf48d43edf4bf27ea6ba2245ddca558ad
Reviewed-on: https://go-review.googlesource.com/50910Reviewed-by: default avatarGiovanni Bajo <rasky@develer.com>
Reviewed-by: default avatarJoe Tsai <thebrokentoaster@gmail.com>
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 4a1be1e1
......@@ -243,3 +243,19 @@ func ExampleMultiWriter() {
// some io.Reader stream to be read
// some io.Reader stream to be read
}
func ExamplePipe() {
r, w := io.Pipe()
go func() {
fmt.Fprint(w, "some text to be read\n")
w.Close()
}()
buf := new(bytes.Buffer)
buf.ReadFrom(r)
fmt.Print(buf.String())
// Output:
// some text to be read
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment