Golang bufio.Scan() function example

package bufio

Scan advances the Scanner to the next token, which will then be available through the Bytes or Text method.

Golang bufio.Scan() function usage example

 reader := bufio.NewReader(file)
 scanner := bufio.NewScanner(reader)

 scanner.Split(bufio.ScanBytes)

 for scanner.Scan() {  // continue Scan for next byte
 fmt.Println(scanner.Bytes())
 }

Reference :

http://golang.org/pkg/bufio/#Scanner.Scan

Advertisement