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.
()
| 895 | // line (that is, a single \n character) will produce a slice containing the |
| 896 | // empty string as its single element. |
| 897 | func (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 |