]> Cypherpunks repositories - gostls13.git/commitdiff
bufio: add Writer example
authorAndrew Gerrand <adg@golang.org>
Mon, 12 Aug 2013 03:03:50 +0000 (13:03 +1000)
committerAndrew Gerrand <adg@golang.org>
Mon, 12 Aug 2013 03:03:50 +0000 (13:03 +1000)
Update #5530

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12504044

src/pkg/bufio/example_test.go

index 08a39441e665adabd7897a66934279c86cac0220..3da914142194895ea37e660c621d3835fb251a86 100644 (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)