Bytes returns the contents of the pipe as a []byte, or an error.
()
| 218 | |
| 219 | // Bytes returns the contents of the pipe as a []byte, or an error. |
| 220 | func (p *Pipe) Bytes() ([]byte, error) { |
| 221 | if p.Error() != nil { |
| 222 | return nil, p.Error() |
| 223 | } |
| 224 | data, err := io.ReadAll(p) |
| 225 | if err != nil { |
| 226 | p.SetError(err) |
| 227 | } |
| 228 | return data, p.Error() |
| 229 | } |
| 230 | |
| 231 | // Close closes the pipe's associated reader. This is a no-op if the reader is |
| 232 | // not an [io.Closer]. |