Skip to content

Instantly share code, notes, and snippets.

@hitechqb
Created September 15, 2019 14:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hitechqb/e451f96ac0acc5b2db05a45d00c8b32c to your computer and use it in GitHub Desktop.
Save hitechqb/e451f96ac0acc5b2db05a45d00c8b32c 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