implemented google 2.1 (timeouts)
This commit is contained in:
parent
75c6be5861
commit
d09e496387
10
search.go
10
search.go
@ -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
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user