go fmt
This commit is contained in:
parent
353a7ef9ee
commit
1b4f464600
4
main.go
4
main.go
@ -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)
|
||||
|
12
search.go
12
search.go
@ -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++ {
|
||||
|
Loading…
Reference in New Issue
Block a user