Skip to content

Commit 2b5df81

Browse files
Saving changes
1 parent bc14920 commit 2b5df81

2 files changed

Lines changed: 8 additions & 13 deletions

File tree

‎src/chapter2/search/main.go‎

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ func main() {
2121

2222
// Perpare the slice of results and the channel to
2323
// retrieve the results on.
24-
var results []rss.SearchResult
2524
captureResults := make(chan []rss.SearchResult)
2625

2726
// Launch goroutines to find us our results.
@@ -34,12 +33,10 @@ func main() {
3433
select {
3534
case findResults := <-captureResults:
3635
for _, result := range findResults {
37-
results = append(results, result)
36+
display(result)
3837
}
3938
}
4039
}
41-
42-
display(results)
4340
}
4441

4542
// find pulls down each feed and searches for the results.
@@ -74,13 +71,11 @@ func find(searchTerm string, site feeds.Site, captureResults chan []rss.SearchRe
7471
}
7572

7673
// display logs the results of the serach to the console.
77-
func display(results []rss.SearchResult) {
78-
for _, result := range results {
79-
switch result.Field {
80-
case "Title":
81-
log.Printf("Title:\n%s\n\n", result.Document.Title)
82-
case "Description":
83-
log.Printf("Description:\n%s\n\n", result.Document.Description)
84-
}
74+
func display(result rss.SearchResult) {
75+
switch result.Field {
76+
case "Title":
77+
log.Printf("Title:\n%s\n\n", result.Document.Title)
78+
case "Description":
79+
log.Printf("Description:\n%s\n\n", result.Document.Description)
8580
}
8681
}

‎src/chapter2/search/rss/rss.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ func Search(document Document, searchTerm string) ([]SearchResult, error) {
111111
return nil, err
112112
}
113113

114-
// If we found as match save the result.
114+
// If we found a match so save the result.
115115
if matched {
116116
searchResults = append(searchResults, SearchResult{
117117
Field: "Description",

0 commit comments

Comments
 (0)