aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Downs <brian.downs@gmail.com>2017-07-15 16:55:41 -0600
committerBryan Mills <bcmills@google.com>2017-07-16 03:49:43 +0000
commitcd619caff4f27496843542cdee0169821784c4b5 (patch)
treed03f3d82e2dbdaaa4b5abd4c43ba5a6ee52d5b9f
parent91afca94e07aa1366afba9ece04c2def9f99d4c4 (diff)
downloadgo-cd619caff4f27496843542cdee0169821784c4b5.tar.gz
go-cd619caff4f27496843542cdee0169821784c4b5.zip
bytes: add example for (*Buffer).Grow
Change-Id: I04849883dd2e1f6d083e9f57d2a8c1bd7d258953 Reviewed-on: https://go-review.googlesource.com/48878 Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
-rw-r--r--src/bytes/example_test.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/bytes/example_test.go b/src/bytes/example_test.go
index 0d35a0dc9c..93972770ab 100644
--- a/src/bytes/example_test.go
+++ b/src/bytes/example_test.go
@@ -30,6 +30,15 @@ func ExampleBuffer_reader() {
// Output: Gophers rule!
}
+func ExampleBuffer_Grow() {
+ var b bytes.Buffer
+ b.Grow(64)
+ bb := b.Bytes()
+ b.Write([]byte("64 bytes or fewer"))
+ fmt.Printf("%q", bb[:b.Len()])
+ // Output: "64 bytes or fewer"
+}
+
func ExampleCompare() {
// Interpret Compare's result by comparing it to zero.
var a, b []byte