parallelize the searching
This commit is contained in:
parent
694b5c30b9
commit
75c6be5861
12
search.go
12
search.go
@ -26,8 +26,14 @@ func fakeSearch(kind string) Search {
|
||||
}
|
||||
|
||||
func Google(query string) (results []Result) {
|
||||
results = append(results, Web(query))
|
||||
results = append(results, Image(query))
|
||||
results = append(results, Video(query))
|
||||
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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user