Standard library / bufio

bufio.ScanWords()

Returns nonempty Unicode whitespace-delimited tokens, not punctuation-aware natural-language words. Expected stdout: '3 ab <nil>\n'.

Formal Syntax & Structure

go syntaxgo
func ScanWords(data []byte, atEOF bool) (advance int, token []byte, err error)

Parameters & Attributes

NameTypeDescription
data[]byteInput bytes or destination storage, according to operation.
atEOFboolWhether the source has reached end of input.

Return Value

(advance int, token []byte, err error)

Returns nonempty Unicode whitespace-delimited tokens, not punctuation-aware natural-language words.

Working Example

Example Snippetgo
package main
import (  "bufio"  "fmt")
func main() { a, t, e := bufio.ScanWords([]byte("ab cd"), false); fmt.Println(a, string(t), e) }
Go Reference