O'Reilly logo
  • Rakesh Mandava thinks this is interesting:

Each time dup reads a line of input, the line is used as a key into the map and the corresponding value is incremented.


Cover of The Go Programming Language


func (Scanner) Scan func (s Scanner) Scan() bool Scan advances the Scanner to the next token, which will then be available through the Bytes or Text method. It returns false when the scan stops, either by reaching the end of the input or an error. After Scan returns false, the Err method will return any error that occurred during scanning, except that if it was io.EOF, Err will return nil. Scan panics if the split function returns too many empty tokens without advancing the input. This is a common error mode for scanners.

func (Scanner) Text func (s Scanner) Text() string Text returns the most recent token generated by a call to Scan as a newly allocated string holding its bytes.