From: Brian Downs Date: Sat, 15 Jul 2017 22:55:41 +0000 (-0600) Subject: bytes: add example for (*Buffer).Grow X-Git-Tag: go1.9rc1~36 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=cd619caff4f27496843542cdee0169821784c4b5;p=gostls13.git 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 --- 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