From d09e496387ff4c023cb2ca50cae2cdb5c2e16eaf Mon Sep 17 00:00:00 2001 From: Stephen McQuay Date: Tue, 14 May 2013 21:00:59 -0700 Subject: [PATCH] implemented google 2.1 (timeouts) --- search.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/search.go b/search.go index 9cb1252..d87d8c8 100644 --- a/search.go +++ b/search.go @@ -31,9 +31,15 @@ func Google(query string) (results []Result) { go func(){c <- Image(query)}() go func(){c <- Video(query)}() + timeout := time.After(80 * time.Millisecond) for i :=0; i < 3; i++ { - result := <-c - results = append(results, result) + select{ + case result := <- c: + results = append(results, result) + case <- timeout: + fmt.Println("timed out!!") + return + } } return }