diff --git a/src/chapter2/search/find/find.go b/src/chapter2/search/find/find.go index e618840..faf7687 100644 --- a/src/chapter2/search/find/find.go +++ b/src/chapter2/search/find/find.go @@ -1,9 +1,6 @@ package find -import ( - "log" - "sync" -) +import "log" type ( // Result contains the result of a search. @@ -19,12 +16,7 @@ type ( ) // Search pulls down each feed looking for the search term. -func Search(matcher Matcher, searchTerm string, result chan Result, waitGroup *sync.WaitGroup) { - // Call done so we can report we are finished processing. - defer func() { - waitGroup.Done() - }() - +func Search(matcher Matcher, searchTerm string, result chan Result) { // Search the data for the search term. searchResults, err := matcher.Match(searchTerm) if err != nil { diff --git a/src/chapter2/search/main.go b/src/chapter2/search/main.go index 6ed7a9b..95b8da4 100644 --- a/src/chapter2/search/main.go +++ b/src/chapter2/search/main.go @@ -49,7 +49,10 @@ func main() { } // Launch the goroutine to perform the search. - go find.Search(matcher, searchTerm, result, &waitGroup) + go func() { + find.Search(matcher, searchTerm, result) + waitGroup.Done() + }() } // Wait for everything to be processed.