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

Method Slice

script.go:897–903  ·  view source on GitHub ↗

Slice returns the pipe's contents as a slice of strings, one element per line, or an error. An empty pipe will produce an empty slice. A pipe containing a single empty line (that is, a single \n character) will produce a slice containing the empty string as its single element.

()

Source from the content-addressed store, hash-verified

895// line (that is, a single \n character) will produce a slice containing the
896// empty string as its single element.
897func (p *Pipe) Slice() ([]string, error) {
898 result := []string{}
899 p.FilterScan(func(line string, w io.Writer) {
900 result = append(result, line)
901 }).Wait()
902 return result, p.Error()
903}
904
905// stdErr returns the pipe's configured standard error writer for commands run
906// via [Pipe.Exec] and [Pipe.ExecForEach]. The default is nil, which means that

Callers 6

FreqMethod · 0.80
TestColumnSelectsFunction · 0.80
TestFreqHandlesLongLinesFunction · 0.80
TestSliceSink_Function · 0.80
ExamplePipe_SliceFunction · 0.80

Calls 3

FilterScanMethod · 0.95
ErrorMethod · 0.95
WaitMethod · 0.80

Tested by 5

TestColumnSelectsFunction · 0.64
TestFreqHandlesLongLinesFunction · 0.64
TestSliceSink_Function · 0.64
ExamplePipe_SliceFunction · 0.64