This commit is contained in:
Stephen McQuay 2013-05-14 21:45:01 -07:00
parent 353a7ef9ee
commit 1b4f464600
2 changed files with 8 additions and 8 deletions

View File

@ -2,15 +2,15 @@ package main
import (
"fmt"
"math/rand"
"time"
"math/rand"
)
func main() {
rand.Seed(time.Now().UnixNano())
start := time.Now()
results := Google("golang")
results := Google("golang")
elapsed := time.Since(start)
fmt.Println(results)

View File

@ -33,14 +33,14 @@ func First(query string, replicas ...Search) Result {
func Google(query string) (results []Result) {
c := make(chan Result)
go func() {
c <- First(query, fakeSearch("web 1"), fakeSearch("web 2"))
}()
c <- First(query, fakeSearch("web 1"), fakeSearch("web 2"))
}()
go func() {
c <- First(query, fakeSearch("vid 1"), fakeSearch("vid 2"))
}()
c <- First(query, fakeSearch("vid 1"), fakeSearch("vid 2"))
}()
go func() {
c <- First(query, fakeSearch("img 1"), fakeSearch("img 2"))
}()
c <- First(query, fakeSearch("img 1"), fakeSearch("img 2"))
}()
timeout := time.After(80 * time.Millisecond)
for i := 0; i < 3; i++ {