parallelize the searching
This commit is contained in:
@@ -26,8 +26,14 @@ func fakeSearch(kind string) Search {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Google(query string) (results []Result) {
|
func Google(query string) (results []Result) {
|
||||||
results = append(results, Web(query))
|
c := make(chan Result)
|
||||||
results = append(results, Image(query))
|
go func(){c <- Web(query)}()
|
||||||
results = append(results, Video(query))
|
go func(){c <- Image(query)}()
|
||||||
|
go func(){c <- Video(query)}()
|
||||||
|
|
||||||
|
for i :=0; i < 3; i++ {
|
||||||
|
result := <-c
|
||||||
|
results = append(results, result)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user