Stdout copies the pipe's contents to its configured standard output (using [Pipe.WithStdout]), or to [os.Stdout] otherwise, and returns the number of bytes successfully written, together with any error.
()
| 918 | // [Pipe.WithStdout]), or to [os.Stdout] otherwise, and returns the number of |
| 919 | // bytes successfully written, together with any error. |
| 920 | func (p *Pipe) Stdout() (int, error) { |
| 921 | if p.Error() != nil { |
| 922 | return 0, p.Error() |
| 923 | } |
| 924 | n64, err := io.Copy(p.stdout, p) |
| 925 | if err != nil { |
| 926 | return 0, err |
| 927 | } |
| 928 | n := int(n64) |
| 929 | if int64(n) != n64 { |
| 930 | return 0, fmt.Errorf("length %d overflows int", n64) |
| 931 | } |
| 932 | return n, p.Error() |
| 933 | } |
| 934 | |
| 935 | // String returns the pipe's contents as a string, together with any error. |
| 936 | func (p *Pipe) String() (string, error) { |