Created
November 4, 2013 21:31
-
-
Save kendellfab/7309513 to your computer and use it in GitHub Desktop.
Simple Golang concurrency concept.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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