From cd619caff4f27496843542cdee0169821784c4b5 Mon Sep 17 00:00:00 2001 From: Brian Downs Date: Sat, 15 Jul 2017 16:55:41 -0600 Subject: [PATCH] bytes: add example for (*Buffer).Grow Change-Id: I04849883dd2e1f6d083e9f57d2a8c1bd7d258953 Reviewed-on: https://go-review.googlesource.com/48878 Run-TryBot: Bryan Mills TryBot-Result: Gobot Gobot Reviewed-by: Bryan Mills --- src/bytes/example_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) 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 -- 2.50.0