Tee copies the pipe's contents to each of the supplied writers, like Unix tee(1). If no writers are supplied, the default is the pipe's standard output.
(writers ...io.Writer)
| 945 | // tee(1). If no writers are supplied, the default is the pipe's standard |
| 946 | // output. |
| 947 | func (p *Pipe) Tee(writers ...io.Writer) *Pipe { |
| 948 | teeWriter := p.stdout |
| 949 | if len(writers) > 0 { |
| 950 | teeWriter = io.MultiWriter(writers...) |
| 951 | } |
| 952 | return p.WithReader(io.TeeReader(p.Reader, teeWriter)) |
| 953 | } |
| 954 | |
| 955 | // Wait reads the pipe to completion and returns any error present on |
| 956 | // the pipe, or nil otherwise. This is mostly useful for waiting until |