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)
| 46 | // `NewScannerFunc` as argument, or use `Function()` directly with |
| 47 | // your own `StageFunc`. |
| 48 | func 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). |