aboutsummaryrefslogtreecommitdiff
path: root/src/bytes/example_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/bytes/example_test.go')
-rw-r--r--src/bytes/example_test.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/bytes/example_test.go b/src/bytes/example_test.go
index e5b7b60dbb..41a5e2e5bf 100644
--- a/src/bytes/example_test.go
+++ b/src/bytes/example_test.go
@@ -11,6 +11,7 @@ import (
"io"
"os"
"sort"
+ "strconv"
"unicode"
)
@@ -37,6 +38,18 @@ func ExampleBuffer_Bytes() {
// Output: hello world
}
+func ExampleBuffer_AvailableBuffer() {
+ var buf bytes.Buffer
+ for i := 0; i < 4; i++ {
+ b := buf.AvailableBuffer()
+ b = strconv.AppendInt(b, int64(i), 10)
+ b = append(b, ' ')
+ buf.Write(b)
+ }
+ os.Stdout.Write(buf.Bytes())
+ // Output: 0 1 2 3
+}
+
func ExampleBuffer_Cap() {
buf1 := bytes.NewBuffer(make([]byte, 10))
buf2 := bytes.NewBuffer(make([]byte, 0, 10))