Created
September 15, 2019 14:46
-
-
Save hitechqb/e451f96ac0acc5b2db05a45d00c8b32c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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