diff options
author | Federico Guerinoni <guerinoni.federico@gmail.com> | 2020-11-08 15:35:35 +0100 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2020-11-11 20:51:00 +0000 |
commit | 141fa337ad2f118e4e99dc554e95c336810a07cf (patch) | |
tree | 001318f9e70a554291d742970c60ef23e206670f /src/bytes | |
parent | f2e58c6d4239f27db284dfe442fa62bb3c0c5b23 (diff) | |
download | go-141fa337ad2f118e4e99dc554e95c336810a07cf.tar.gz go-141fa337ad2f118e4e99dc554e95c336810a07cf.zip |
bytes: add example for (*Buffer).Bytes
Change-Id: I49ac604530fff7928fa15de07563418b104da5e4
Reviewed-on: https://go-review.googlesource.com/c/go/+/268260
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Giovanni Bajo <rasky@develer.com>
Diffstat (limited to 'src/bytes')
-rw-r--r-- | src/bytes/example_test.go | 7 |
1 files changed, 7 insertions, 0 deletions
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) |