From: Federico Guerinoni Date: Sun, 8 Nov 2020 14:35:35 +0000 (+0100) Subject: bytes: add example for (*Buffer).Bytes X-Git-Tag: go1.16beta1~249 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=141fa337ad;p=gostls13.git bytes: add example for (*Buffer).Bytes Change-Id: I49ac604530fff7928fa15de07563418b104da5e4 Reviewed-on: https://go-review.googlesource.com/c/go/+/268260 Run-TryBot: Ian Lance Taylor TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor Trust: Giovanni Bajo --- diff --git a/src/bytes/example_test.go b/src/bytes/example_test.go index 5ba7077c1d..ae93202b57 100644 --- a/src/bytes/example_test.go +++ b/src/bytes/example_test.go @@ -30,6 +30,13 @@ func ExampleBuffer_reader() { // Output: Gophers rule! } +func ExampleBuffer_Bytes() { + buf := bytes.Buffer{} + buf.Write([]byte{'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd'}) + os.Stdout.Write(buf.Bytes()) + // Output: hello world +} + func ExampleBuffer_Grow() { var b bytes.Buffer b.Grow(64)