From 75c6be5861decc90368bc926079b5a6656457675 Mon Sep 17 00:00:00 2001 From: Stephen McQuay Date: Tue, 14 May 2013 20:57:11 -0700 Subject: [PATCH] parallelize the searching --- search.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/search.go b/search.go index 3c04cf2..9cb1252 100644 --- a/search.go +++ b/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 }