Commit cd619caf authored by Brian Downs's avatar Brian Downs Committed by Bryan Mills

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: default avatarBryan Mills <bcmills@google.com>
parent 91afca94
...@@ -30,6 +30,15 @@ func ExampleBuffer_reader() { ...@@ -30,6 +30,15 @@ func ExampleBuffer_reader() {
// Output: Gophers rule! // 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() { func ExampleCompare() {
// Interpret Compare's result by comparing it to zero. // Interpret Compare's result by comparing it to zero.
var a, b []byte var a, b []byte
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment