Tee (like its Unix namesake) takes a single input channel and an arbitrary number of output channels and duplicates each input into every output. When the input channel is closed, all outputs channels are closed. Tee with a single output channel is equivalent to Pipe (though slightly less efficient)
(input SimpleOutChannel, outputs ...SimpleInChannel)
| 178 | // and duplicates each input into every output. When the input channel is closed, all outputs channels are closed. |
| 179 | // Tee with a single output channel is equivalent to Pipe (though slightly less efficient). |
| 180 | func Tee(input SimpleOutChannel, outputs ...SimpleInChannel) { |
| 181 | if len(outputs) == 0 { |
| 182 | panic("channels: Tee requires at least one output") |
| 183 | } |
| 184 | go tee(input, outputs, true) |
| 185 | } |
| 186 | |
| 187 | // Distribute takes a single input channel and an arbitrary number of output channels and duplicates each input |
| 188 | // into *one* available output. If multiple outputs are waiting for a value, one is chosen at random. When the |