Created
July 17, 2019 14:03
-
-
Save teivah/92ae519c3801df96b708352137922311 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