aboutsummaryrefslogtreecommitdiff
path: root/src/bufio
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2019-06-24 11:54:15 -0700
committerIan Lance Taylor <iant@golang.org>2019-06-25 00:29:24 +0000
commitd1d9ad583df5d6dc58028e1303ddeccb39237220 (patch)
treed06e27be649875275626d5505247c6f9ee8b12c4 /src/bufio
parent5f7e9cedd295fdedc10e1f1673d62da7ca3249b9 (diff)
downloadgo-d1d9ad583df5d6dc58028e1303ddeccb39237220.tar.gz
go-d1d9ad583df5d6dc58028e1303ddeccb39237220.zip
bufio: fix ExampleScanner_Bytes comment, add error check
Followup to CL 51412. Change-Id: Ic83c833e2c571cd7c8293d998ff745f181037a61 Reviewed-on: https://go-review.googlesource.com/c/go/+/183657 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
Diffstat (limited to 'src/bufio')
-rw-r--r--src/bufio/example_test.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/bufio/example_test.go b/src/bufio/example_test.go
index e220e0768f..8885d40549 100644
--- a/src/bufio/example_test.go
+++ b/src/bufio/example_test.go
@@ -31,12 +31,15 @@ func ExampleScanner_lines() {
}
}
-// Use return the most recent call to Scan as a []byte
+// Return the most recent call to Scan as a []byte.
func ExampleScanner_Bytes() {
scanner := bufio.NewScanner(strings.NewReader("gopher"))
for scanner.Scan() {
fmt.Println(len(scanner.Bytes()) == 6)
}
+ if err := scanner.Err(); err != nil {
+ fmt.Fprintln(os.Stderr, "shouldn't see an error scanning a string")
+ }
// Output:
// true
}