Skip to content

Commit d1d9ad5

Browse files
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 <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Rob Pike <[email protected]>
1 parent 5f7e9ce commit d1d9ad5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/bufio/example_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,15 @@ func ExampleScanner_lines() {
3131
}
3232
}
3333

34-
// Use return the most recent call to Scan as a []byte
34+
// Return the most recent call to Scan as a []byte.
3535
func ExampleScanner_Bytes() {
3636
scanner := bufio.NewScanner(strings.NewReader("gopher"))
3737
for scanner.Scan() {
3838
fmt.Println(len(scanner.Bytes()) == 6)
3939
}
40+
if err := scanner.Err(); err != nil {
41+
fmt.Fprintln(os.Stderr, "shouldn't see an error scanning a string")
42+
}
4043
// Output:
4144
// true
4245
}

0 commit comments

Comments
 (0)