Documentation ¶
Overview ¶
Package util provides some helpful functions.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MultiToken ¶
type MultiToken []rune
MultiToken represents a run of runes that can be used to tokenize a stream of runes.
func NewMultiToken ¶
func NewMultiToken(s string) MultiToken
func (MultiToken) ScanToken ¶
func (m MultiToken) ScanToken(rd *bufio.Reader) (rns []rune, err error)
ScanToken returns the run of runes terminated by m, not including the terminator.
Example ¶
const input = "hi\r\nhow\r\nare\r\nyou" var tok = MultiToken([]rune{'\r', '\n'}) r := bufio.NewReader(strings.NewReader(input)) for { rs, err := tok.ScanToken(r) if err != nil { fmt.Println(err) return } fmt.Printf("Got input: %s\n", string(rs)) }
Output: Got input: hi Got input: how Got input: are EOF
Click to show internal directories.
Click to hide internal directories.