shad-go/lectures/09-io/pipe/main.go
2020-04-23 04:40:13 +03:00

20 lines
243 B
Go

package main
import (
"bytes"
"fmt"
"io"
)
func main() {
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())
}