Skip to content

Instantly share code, notes, and snippets.

@teivah
Created July 17, 2019 14:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save teivah/92ae519c3801df96b708352137922311 to your computer and use it in GitHub Desktop.
Save teivah/92ae519c3801df96b708352137922311 to your computer and use it in GitHub Desktop.
func count(reader *bufio.Reader) (int, error) {
count := 0
for {
line, _, err := reader.ReadLine()
if err != nil {
switch err {
default:
return 0, errors.Wrapf(err, "unable to read")
case io.EOF:
return count, nil
}
}
if len(line) == 0 {
count++
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment