Skip to content

Instantly share code, notes, and snippets.

@just1689
Last active April 8, 2018 11:20
Show Gist options
  • Save just1689/b8a3a451367cbba2865c375f4f4d5cbb to your computer and use it in GitHub Desktop.
Save just1689/b8a3a451367cbba2865c375f4f4d5cbb to your computer and use it in GitHub Desktop.
Process data coming back later
func main() {
in := gen(2, 3)
// Distribute the sq work across two goroutines that both read from in.
c1 := sq(in)
c2 := sq(in)
// Consume the merged output from c1 and c2.
for n := range merge(c1, c2) {
fmt.Println(n) // 4 then 9, or 9 then 4
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment