1
0
mirror of https://github.com/golang/go synced 2024-09-23 13:20:14 -06:00

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>
This commit is contained in:
Brian Downs 2017-07-15 16:55:41 -06:00 committed by Bryan Mills
parent 91afca94e0
commit cd619caff4

View 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