]> Cypherpunks repositories - gostls13.git/commitdiff
bytes: add example for Buffer.Len
authorErin Masatsugu <erin.masatsugu@gmail.com>
Thu, 30 Aug 2018 18:27:07 +0000 (18:27 +0000)
committerIan Lance Taylor <iant@golang.org>
Thu, 30 Aug 2018 19:10:14 +0000 (19:10 +0000)
Change-Id: Ide50aba940727a7b32cd33dea5315050f1a34717
Reviewed-on: https://go-review.googlesource.com/132237
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/bytes/example_test.go

index 5b7a46058f5c73b44ec111b411d9580ae5c3f7ff..4d5cdfa28095ef953067ee12b64e260038a2913a 100644 (file)
@@ -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