1
0
mirror of https://github.com/golang/go synced 2024-11-25 09:47:57 -07:00

bufio: add Writer example

Update #5530

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12504044
This commit is contained in:
Andrew Gerrand 2013-08-12 13:03:50 +10:00
parent 6b706cf50d
commit 8eb8ad2454

View File

@ -12,6 +12,14 @@ import (
"strings"
)
func ExampleWriter() {
w := bufio.NewWriter(os.Stdout)
fmt.Fprint(w, "Hello, ")
fmt.Fprint(w, "world!")
w.Flush() // Don't forget to flush!
// Output: Hello, world!
}
// The simplest use of a Scanner, to read standard input as a set of lines.
func ExampleScanner_lines() {
scanner := bufio.NewScanner(os.Stdin)