Skip to content

Instantly share code, notes, and snippets.

@kendellfab
Created November 4, 2013 21:31
Show Gist options
  • Save kendellfab/7309513 to your computer and use it in GitHub Desktop.
Save kendellfab/7309513 to your computer and use it in GitHub Desktop.
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