MCPcopy Index your code
hub / github.com/github/git-sizer / LinewiseFunction

Function LinewiseFunction

internal/pipe/linewise.go:48–59  ·  view source on GitHub ↗

LinewiseFunction returns a function-based `Stage`. The input will be split into LF-terminated lines and passed to the function one line at a time (without the LF). The function may emit output to its `stdout` argument. See the definition of `LinewiseStageFunc` for more information. Note that the st

(name string, f LinewiseStageFunc)

Source from the content-addressed store, hash-verified

46// `NewScannerFunc` as argument, or use `Function()` directly with
47// your own `StageFunc`.
48func LinewiseFunction(name string, f LinewiseStageFunc) Stage {
49 return ScannerFunction(
50 name,
51 func(r io.Reader) (Scanner, error) {
52 scanner := bufio.NewScanner(r)
53 // Split based on strict LF (we don't accept CRLF):
54 scanner.Split(ScanLFTerminatedLines)
55 return scanner, nil
56 },
57 f,
58 )
59}
60
61// ScanLFTerminatedLines is a `bufio.SplitFunc` that splits its input
62// into lines at LF characters (not treating CR specially).

Callers 4

NewObjectIterMethod · 0.92
TestScannerAlwaysFlushesFunction · 0.92
TestScannerFinishEarlyFunction · 0.92

Calls 1

ScannerFunctionFunction · 0.85

Tested by 3

TestScannerAlwaysFlushesFunction · 0.74
TestScannerFinishEarlyFunction · 0.74