mirror of
https://github.com/golang/go
synced 2024-11-24 19:30:42 -07:00
bufio: add example for Scanner.Bytes
Change-Id: I4a5c7573e13dd85531ee9f4dd2a0d1981bf8cdfa Reviewed-on: https://go-review.googlesource.com/c/go/+/51412 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
1130cc745d
commit
44c9354c5a
@ -31,6 +31,16 @@ func ExampleScanner_lines() {
|
||||
}
|
||||
}
|
||||
|
||||
// Use 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)
|
||||
}
|
||||
// Output:
|
||||
// true
|
||||
}
|
||||
|
||||
// Use a Scanner to implement a simple word-count utility by scanning the
|
||||
// input as a sequence of space-delimited tokens.
|
||||
func ExampleScanner_words() {
|
||||
|
Loading…
Reference in New Issue
Block a user