Nit: fix use of bufio.Scanner.Err

The Err() method should be called after the Scan() loop, not inside it.

Found by: git grep -A3 -F '.Scan()'

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
Kir Kolyshkin
2020-03-11 19:36:21 -07:00
parent c6851ace61
commit 6e638ad27a
3 changed files with 7 additions and 10 deletions

View File

@@ -45,10 +45,6 @@ func parseInfoFile(r io.Reader) ([]Info, error) {
out := []Info{}
var err error
for s.Scan() {
if err = s.Err(); err != nil {
return nil, err
}
/*
See http://man7.org/linux/man-pages/man5/proc.5.html
@@ -128,6 +124,10 @@ func parseInfoFile(r io.Reader) ([]Info, error) {
out = append(out, p)
}
if err = s.Err(); err != nil {
return nil, err
}
return out, nil
}