Standard library / bufio
bufio.Scanner.Split()
Selects the tokenizing function before scanning begins; calling it after Scan panics. Expected stdout: 'a\nb\n'.
Formal Syntax & Structure
go syntaxgo
func (s *Scanner) Split(split SplitFunc)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| split | SplitFunc | Tokenizing callback. |
Working Example
Example Snippetgo
package main
import ( "bufio" "fmt" "strings")
func main() { s := bufio.NewScanner(strings.NewReader("a b")) s.Split(bufio.ScanWords) for s.Scan() { fmt.Println(s.Text()) } if s.Err() != nil { panic(s.Err()) }}