(input io.Reader, lineFn func([]byte), readCallback func())
| 59 | } |
| 60 | |
| 61 | func StreamToLines(input io.Reader, lineFn func([]byte), readCallback func()) error { |
| 62 | var lineBuf lineBuf |
| 63 | readBuf := make([]byte, 64*1024) |
| 64 | for { |
| 65 | n, err := input.Read(readBuf) |
| 66 | streamToLines_processBuf(&lineBuf, readBuf[:n], lineFn) |
| 67 | if err != nil { |
| 68 | return err |
| 69 | } |
| 70 | if readCallback != nil { |
| 71 | readCallback() |
| 72 | } |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | // starts a goroutine to drive the channel |
| 77 | // line output does not include the trailing newline |
no test coverage detected