Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Simple Golang concurrency concept.
// http://talks.golang.org/2012/concurrency.slide
func Google(query string) (results []Result) {
c := make(chan Result)
go func() { c <- Web(query) } ()
go func() { c <- Image(query) } ()
go func() { c <- Video(query) } ()
for i := 0; i < 3; i++ {
result := <-c
results = append(results, result)
}
return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment