Files
learngo/interfaces/log-parser/01-methods/main.go

40 lines
653 B
Go
Raw Normal View History

2019-08-17 15:55:25 +03:00
// For more tutorials: https://blog.learngoprogramming.com
//
// Copyright © 2018 Inanc Gumus
// Learn Go Programming Course
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
//
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
p := newParser()
2019-08-19 10:21:11 +03:00
fmt.Printf("%T\n", (*parser).parse)
return
2019-08-17 15:55:25 +03:00
in := bufio.NewScanner(os.Stdin)
for in.Scan() {
2019-08-19 10:21:11 +03:00
parsed := p.parse(in.Text())
p.update(parsed)
2019-08-17 15:55:25 +03:00
}
2019-08-19 10:21:11 +03:00
p.summarize()
dumpErrs([]error{in.Err(), p.err()})
2019-08-17 15:55:25 +03:00
}
2019-08-19 10:21:11 +03:00
// dumpErrs together to simplify multiple error handling
2019-08-17 15:55:25 +03:00
func dumpErrs(errs []error) {
for _, err := range errs {
if err != nil {
fmt.Println("> Err:", err)
}
}
}