]> Cypherpunks repositories - gostls13.git/commitdiff
bytes: add example for Len function of Reader
authorAndrzej Żeżel <andrii.zhezhel@gmail.com>
Sat, 16 Sep 2017 14:58:10 +0000 (16:58 +0200)
committerIan Lance Taylor <iant@golang.org>
Sun, 17 Sep 2017 00:02:19 +0000 (00:02 +0000)
Change-Id: If7ecdc57f190f647bfc673bde8e66b4ef12aa906
Reviewed-on: https://go-review.googlesource.com/64190
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/bytes/example_test.go

index a112c9a37363e0ad061d828f53d3bda3a8aede35..252be8c473d71f60ba341dda2f585dcf88197f57 100644 (file)
@@ -412,3 +412,13 @@ func ExampleToLower() {
        fmt.Printf("%s", bytes.ToLower([]byte("Gopher")))
        // Output: gopher
 }
+
+func ExampleReader_Len() {
+       fmt.Println(bytes.NewReader([]byte("")).Len())
+       fmt.Println(bytes.NewReader([]byte("Hi!")).Len())
+       fmt.Println(bytes.NewReader([]byte("Hello Gopher!")).Len())
+       // Output:
+       // 0
+       // 3
+       // 13
+}