]> Cypherpunks repositories - gostls13.git/commitdiff
bufio: fix ExampleScanner_Bytes comment, add error check
authorIan Lance Taylor <iant@golang.org>
Mon, 24 Jun 2019 18:54:15 +0000 (11:54 -0700)
committerIan Lance Taylor <iant@golang.org>
Tue, 25 Jun 2019 00:29:24 +0000 (00:29 +0000)
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>
src/bufio/example_test.go

index e220e0768f1fd2ce569f9e58a376bec0d658ec59..8885d40549f1532010a320d00964f19bffbb5846 100644 (file)
@@ -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
 }