Concat reads paths from the pipe, one per line, and produces the contents of all the corresponding files in sequence. If there are any errors (for example, non-existent files), these will be ignored, execution will continue, and the pipe's error status will not be set. This makes it convenient to w
()
| 269 | // without setting the pipe's error status. This mimics the behaviour of Unix |
| 270 | // cat(1). |
| 271 | func (p *Pipe) Concat() *Pipe { |
| 272 | var readers []io.Reader |
| 273 | p.FilterScan(func(line string, w io.Writer) { |
| 274 | input, err := os.Open(line) |
| 275 | if err == nil { |
| 276 | readers = append(readers, NewReadAutoCloser(input)) |
| 277 | } |
| 278 | }).Wait() |
| 279 | return p.WithReader(io.MultiReader(readers...)) |
| 280 | } |
| 281 | |
| 282 | // CountLines returns the number of lines of input, or an error. |
| 283 | func (p *Pipe) CountLines() (lines int, err error) { |