Implement the Merge
function that takes a variable number of input channels and returns a single output channel. The output channel should receive all values from all input channels. Once all input channels are closed and all values have been sent to the output channel, the output channel should be closed.
Requirements:
- The function should handle any number of input channels, including zero.
- All values from all input channels must be sent to the output channel.
- The output channel should be closed only after all input channels are closed and all values have been forwarded.
- Your implementation must not leak goroutines.
- Values should be forwarded as soon as they are available from any input channel.
Concurrency