rename: logparser v5 -> v6

This commit is contained in:
Inanc Gumus
2019-08-28 22:52:28 +03:00
parent de97595895
commit 10140e976d
20 changed files with 20 additions and 20 deletions

View File

@@ -0,0 +1,44 @@
// 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 parse
import (
"bufio"
"io"
"github.com/inancgumus/learngo/logparser/v6/pipe"
)
// Text parses text based log lines.
type Text struct {
reader io.Reader
}
// FromText creates a text parser.
func FromText(r io.Reader) *Text {
return &Text{reader: r}
}
// Each yields records from a text log.
func (p *Text) Each(yield func(pipe.Record)) 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()
}