This commit is contained in:
Stephen McQuay 2013-05-14 21:01:26 -07:00
parent d09e496387
commit f3794ba244
1 changed files with 14 additions and 14 deletions

View File

@ -26,20 +26,20 @@ func fakeSearch(kind string) Search {
} }
func Google(query string) (results []Result) { func Google(query string) (results []Result) {
c := make(chan Result) c := make(chan Result)
go func(){c <- Web(query)}() go func() { c <- Web(query) }()
go func(){c <- Image(query)}() go func() { c <- Image(query) }()
go func(){c <- Video(query)}() go func() { c <- Video(query) }()
timeout := time.After(80 * time.Millisecond) timeout := time.After(80 * time.Millisecond)
for i :=0; i < 3; i++ { for i := 0; i < 3; i++ {
select{ select {
case result := <- c: case result := <-c:
results = append(results, result) results = append(results, result)
case <- timeout: case <-timeout:
fmt.Println("timed out!!") fmt.Println("timed out!!")
return return
} }
} }
return return
} }