Skip to content

Commit 320e3fc

Browse files
author
gbbr
committed
Plural
1 parent 8df3c5f commit 320e3fc

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

‎chapter7/patterns/search/search.go‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,35 +53,35 @@ func Submit(query string, options ...func(*searchSession)) []Result {
5353
opt(&session)
5454
}
5555

56-
var result []Result
57-
5856
// Perform the searches concurrently. Using a map because
5957
// it returns the searchers in a random order every time.
6058
for _, s := range session.searchers {
6159
go s.Search(query, session.resultChan)
6260
}
6361

62+
var results []Result
63+
6464
// Wait for the results to come back.
6565
for search := 0; search < len(session.searchers); search++ {
6666
// If we just want the first result, don't wait any longer by
6767
// concurrently discarding the remaining searchResults.
6868
// Failing to do so will leave the Searchers blocked forever.
6969
if session.first && search > 0 {
7070
go func() {
71-
result = append(result, <-session.resultChan...)
72-
log.Printf("search : Submit : Info : Results Discarded : Results[%d]\n", len(result))
71+
results = append(results, <-session.resultChan...)
72+
log.Printf("search : Submit : Info : Results Discarded : Results[%d]\n", len(results))
7373
}()
7474
continue
7575
}
7676

7777
// Wait to recieve results.
7878
log.Println("search : Submit : Info : Waiting For Results...")
79-
result = append(result, <-session.resultChan...)
79+
results = append(results, <-session.resultChan...)
8080

8181
// Save the results to the final slice.
82-
log.Printf("search : Submit : Info : Results Used : Results[%d]\n", len(result))
82+
log.Printf("search : Submit : Info : Results Used : Results[%d]\n", len(results))
8383
}
8484

85-
log.Printf("search : Submit : Completed : Found [%d] Results\n", len(result))
86-
return result
85+
log.Printf("search : Submit : Completed : Found [%d] Results\n", len(results))
86+
return results
8787
}

0 commit comments

Comments
 (0)