refactor: logparser v5 funcs
This commit is contained in:
@ -18,16 +18,17 @@ type logCount struct {
|
||||
// Each yields to the inner iterator while counting the records.
|
||||
// Reports the record number on an error.
|
||||
func (lc *logCount) Each(yield func(Record) error) error {
|
||||
err := lc.Iterator.Each(func(r Record) error {
|
||||
count := func(r Record) error {
|
||||
lc.n++
|
||||
return yield(r)
|
||||
})
|
||||
}
|
||||
|
||||
err := lc.Iterator.Each(count)
|
||||
|
||||
if err != nil {
|
||||
// lc.n+1: iterator.each won't call yield on err
|
||||
return fmt.Errorf("record %d: %v", lc.n+1, err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user