Created
September 13, 2017 18:34
-
-
Save vladimirvivien/68a02ae03d793b4821db3b32e0ec8d2e to your computer and use it in GitHub Desktop.
This file contains 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
func main() { | |
proverbs := new(bytes.Buffer) | |
proverbs.WriteString("Channels orchestrate mutexes serialize\n") | |
proverbs.WriteString("Cgo is not Go\n") | |
proverbs.WriteString("Errors are values\n") | |
proverbs.WriteString("Don't panic\n") | |
piper, pipew := io.Pipe() | |
// write in writer end of pipe | |
go func() { | |
defer pipew.Close() | |
io.Copy(pipew, proverbs) | |
}() | |
// read from reader end of pipe. | |
io.Copy(os.Stdout, piper) | |
piper.Close() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment