MCPcopy
hub / github.com/bitfield/script / Concat

Method Concat

script.go:271–280  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

269// without setting the pipe's error status. This mimics the behaviour of Unix
270// cat(1).
271func (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.
283func (p *Pipe) CountLines() (lines int, err error) {

Calls 4

FilterScanMethod · 0.95
WithReaderMethod · 0.95
NewReadAutoCloserFunction · 0.85
WaitMethod · 0.80