]> Cypherpunks repositories - gostls13.git/commitdiff
bytes: add example for (*Buffer).Grow
authorBrian Downs <brian.downs@gmail.com>
Sat, 15 Jul 2017 22:55:41 +0000 (16:55 -0600)
committerBryan Mills <bcmills@google.com>
Sun, 16 Jul 2017 03:49:43 +0000 (03:49 +0000)
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>
src/bytes/example_test.go

index 0d35a0dc9c5c1b473807139411fd5d36912fed2e..93972770ab2449a19e7eeb452999507603c4c397 100644 (file)
@@ -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