From 5e755e9d6d9d5ab1268dc7c2d18a08b543d988c9 Mon Sep 17 00:00:00 2001 From: Erin Masatsugu Date: Thu, 30 Aug 2018 18:27:07 +0000 Subject: [PATCH] bytes: add example for Buffer.Len Change-Id: Ide50aba940727a7b32cd33dea5315050f1a34717 Reviewed-on: https://go-review.googlesource.com/132237 Run-TryBot: Ian Lance Taylor TryBot-Result: Gobot Gobot Reviewed-by: Ian Lance Taylor --- src/bytes/example_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/bytes/example_test.go b/src/bytes/example_test.go index 5b7a46058f..4d5cdfa280 100644 --- a/src/bytes/example_test.go +++ b/src/bytes/example_test.go @@ -39,6 +39,14 @@ func ExampleBuffer_Grow() { // Output: "64 bytes or fewer" } +func ExampleBuffer_Len() { + var b bytes.Buffer + b.Grow(64) + b.Write([]byte("abcde")) + fmt.Printf("%d", b.Len()) + // Output: 5 +} + func ExampleCompare() { // Interpret Compare's result by comparing it to zero. var a, b []byte -- 2.50.0