move: log parsers

This commit is contained in:
Inanc Gumus
2019-08-28 20:23:38 +03:00
parent 0a121cd911
commit 9afbe8f350
123 changed files with 1018 additions and 1515 deletions

39
logparser/oop/textlog.go Normal file
View File

@@ -0,0 +1,39 @@
// For more tutorials: https://bp.learngoprogramming.com
//
// Copyright © 2018 Inanc Gumus
// Learn Go Programming Course
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
//
package main
import (
"bufio"
"io"
)
type textLog struct {
reader io.Reader
}
func newTextLog(r io.Reader) *textLog {
return &textLog{reader: r}
}
func (p *textLog) each(yield recordFn) error {
defer readClose(p.reader)
in := bufio.NewScanner(p.reader)
for in.Scan() {
r := new(record)
if err := r.UnmarshalText(in.Bytes()); err != nil {
return err
}
yield(*r)
}
return in.Err()
}