MCPcopy
hub / github.com/inancgumus/learngo / Each

Method Each

logparser/v5/pipe/logcount.go:21–34  ·  view source on GitHub ↗

Each yields to the inner iterator while counting the records. Reports the record number on an error.

(yield func(Record) error)

Source from the content-addressed store, hash-verified

19// Each yields to the inner iterator while counting the records.
20// Reports the record number on an error.
21func (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.
37func (lc *logCount) count() int {

Callers

nothing calls this directly

Calls 1

EachMethod · 0.65

Tested by

no test coverage detected