Each yields to the inner iterator while counting the records. Reports the record number on an error.
(yield func(Record) error)
| 19 | // Each yields to the inner iterator while counting the records. |
| 20 | // Reports the record number on an error. |
| 21 | func (lc *logCount) Each(yield func(Record) error) error { |
| 22 | count := func(r Record) error { |
| 23 | lc.n++ |
| 24 | return yield(r) |
| 25 | } |
| 26 | |
| 27 | err := lc.Iterator.Each(count) |
| 28 | |
| 29 | if err != nil { |
| 30 | // lc.n+1: iterator.each won't call yield on err |
| 31 | return fmt.Errorf("record %d: %v", lc.n+1, err) |
| 32 | } |
| 33 | return nil |
| 34 | } |
| 35 | |
| 36 | // count returns the last read record number. |
| 37 | func (lc *logCount) count() int { |