Standard library / bufio
bufio.Scanner
Convenient token reader with bounded token buffer and configurable split function. Not suitable for arbitrary-size records without explicit limits. Expected stdout: 'one\ntwo\n'.
Formal Syntax & Structure
go syntaxgo
type Scanner struct { /* unexported fields */ }Working Example
Example Snippetgo
package main
import ( "bufio" "fmt" "strings")
func main() { var s *bufio.Scanner = bufio.NewScanner(strings.NewReader("one two")) s.Split(bufio.ScanWords) for s.Scan() { fmt.Println(s.Text()) } if s.Err() != nil { panic(s.Err()) }}