fix: project log parser

This commit is contained in:
Inanc Gumus
2019-04-25 14:05:02 +03:00
parent f337a14154
commit b7c3daf4e4
5 changed files with 23 additions and 11 deletions

View File

@@ -27,8 +27,7 @@ func main() {
)
// Scan the standard-in line by line
for line := 0; in.Scan(); line++ {
for line := 1; in.Scan(); line++ {
// Parse the fields
fields := strings.Fields(in.Text())
if len(fields) != 2 {
@@ -43,8 +42,8 @@ func main() {
}
// Sum the total visits per domain
n, _ := strconv.Atoi(visits)
if n < 0 {
n, err := strconv.Atoi(visits)
if n < 0 || err != nil {
fmt.Printf("wrong input: %q (line #%d)\n", visits, line)
return
}