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:
parent
91afca94e0
commit
cd619caff4
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user