Skip to content

Instantly share code, notes, and snippets.

@campoy
Created January 29, 2018 07:07
Show Gist options
  • Save campoy/84d3f25823575ef4ba8bf94f6c90ac5a to your computer and use it in GitHub Desktop.
Save campoy/84d3f25823575ef4ba8bf94f6c90ac5a to your computer and use it in GitHub Desktop.
func merge(cs ...<-chan int) <-chan int {
out := make(chan int)
for _, c := range cs {
go func() {
for v := range c {
out <- v
}
}()
}
return out
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment