aboutsummaryrefslogtreecommitdiff
path: root/src/bufio/example_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/bufio/example_test.go')
-rw-r--r--src/bufio/example_test.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/bufio/example_test.go b/src/bufio/example_test.go
index 8885d40549f..a864d11012e 100644
--- a/src/bufio/example_test.go
+++ b/src/bufio/example_test.go
@@ -20,6 +20,18 @@ func ExampleWriter() {
// Output: Hello, world!
}
+func ExampleWriter_AvailableBuffer() {
+ w := bufio.NewWriter(os.Stdout)
+ for _, i := range []int64{1, 2, 3, 4} {
+ b := w.AvailableBuffer()
+ b = strconv.AppendInt(b, i, 10)
+ b = append(b, ' ')
+ w.Write(b)
+ }
+ w.Flush()
+ // Output: 1 2 3 4
+}
+
// The simplest use of a Scanner, to read standard input as a set of lines.
func ExampleScanner_lines() {
scanner := bufio.NewScanner(os.Stdin)