implemented google 2.1 (timeouts)

This commit is contained in:
Stephen McQuay 2013-05-14 21:00:59 -07:00
parent 75c6be5861
commit d09e496387

View File

@ -31,9 +31,15 @@ func Google(query string) (results []Result) {
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)
for i :=0; i < 3; i++ { for i :=0; i < 3; i++ {
result := <-c select{
results = append(results, result) case result := <- c:
results = append(results, result)
case <- timeout:
fmt.Println("timed out!!")
return
}
} }
return return
} }