import "golang.org/x/build/internal/foreach"
Package foreach provides allocation-conscious helpers for iterating over lines of text.
They're factored out into a separate small package primarily to allow them to have allocation-measuring tests that need to run without interference from other goroutine-leaking tests.
Line calls f on each line in v, without the trailing '\n'. The final line need not include a trailing '\n'. Returns first non-nil error returned by f.
Code:
v := []byte(`line 1 line 2 line 3 after two blank lines last line`) foreach.Line(v, func(b []byte) error { fmt.Printf("%q\n", b) return nil })
Output:
"line 1" "line 2" "line 3" "" "" "after two blank lines" "last line"
LineStr calls f on each line in s, without the trailing '\n'. The final line need not include a trailing '\n'. Returns first non-nil error returned by f.
LineStr is the string variant of Line.
Package foreach imports 2 packages (graph) and is imported by 9 packages. Updated 2021-01-22. Refresh now. Tools for package owners.