@@ -18,92 +18,77 @@ func init() {
1818// Google provides support for Google searches.
1919type google struct {}
2020
21- // NewGoogle returns a Google Searcher value.
22- func NewGoogle () google {
23- return google {}
24- }
25-
2621// Search implements the Searcher interface. It performs a search
2722// against Google.
28- func (g google ) Search (searchTerm string , searchResults chan <- []Result ) {
29- log .Printf ("Google : Search : Started : searchTerm [%s]\n " , searchTerm )
23+ func (g google ) Search (term string , results chan <- []Result ) {
24+ log .Printf ("Google : Search : Started : search term [%s]\n " , term )
3025
3126 // Slice for the results.
32- var results []Result
27+ var r []Result
3328
3429 // Simulate an amount of time for the search.
3530 time .Sleep (time .Millisecond * time .Duration (rand .Int63n (900 )))
3631
3732 // Simulate a result for the search.
38- results = append (results , Result {
33+ r = append (r , Result {
3934 Engine : "Google" ,
4035 Title : "The Go Programming Language" ,
4136 Description : "The Go Programming Language" ,
4237 Link : "https://golang.org/" ,
4338 })
4439
45- log .Printf ("Google : Search : Completed : Found[%d]\n " , len (results ))
46- searchResults <- results
40+ log .Printf ("Google : Search : Completed : Found[%d]\n " , len (r ))
41+ results <- r
4742}
4843
4944// Bing provides support for Bing searches.
5045type bing struct {}
5146
52- // NewBing returns a Bing Searcher value.
53- func NewBing () bing {
54- return bing {}
55- }
56-
5747// Search implements the Searcher interface. It performs a search
5848// against Bing.
59- func (b bing ) Search (searchTerm string , searchResults chan <- []Result ) {
60- log .Printf ("Bing : Search : Started : searchTerm [%s]\n " , searchTerm )
49+ func (b bing ) Search (term string , results chan <- []Result ) {
50+ log .Printf ("Bing : Search : Started : search term [%s]\n " , term )
6151
6252 // Slice for the results.
63- var results []Result
53+ var r []Result
6454
6555 // Simulate an amount of time for the search.
6656 time .Sleep (time .Millisecond * time .Duration (rand .Int63n (900 )))
6757
6858 // Simulate a result for the search.
69- results = append (results , Result {
59+ r = append (r , Result {
7060 Engine : "Bing" ,
7161 Title : "A Tour of Go" ,
7262 Description : "Welcome to a tour of the Go programming language." ,
7363 Link : "http://tour.golang.org/" ,
7464 })
7565
76- log .Printf ("Bing : Search : Completed : Found[%d]\n " , len (results ))
77- searchResults <- results
66+ log .Printf ("Bing : Search : Completed : Found[%d]\n " , len (r ))
67+ results <- r
7868}
7969
8070// Yahoo provides support for Yahoo searches.
8171type yahoo struct {}
8272
83- // NewYahoo returns a Yahoo Searcher value.
84- func NewYahoo () yahoo {
85- return yahoo {}
86- }
87-
8873// Search implements the Searcher interface. It performs a search
8974// against Yahoo.
90- func (y yahoo ) Search (searchTerm string , searchResults chan <- []Result ) {
91- log .Printf ("Yahoo : Search : Started : searchTerm [%s]\n " , searchTerm )
75+ func (y yahoo ) Search (term string , results chan <- []Result ) {
76+ log .Printf ("Yahoo : Search : Started : search term [%s]\n " , term )
9277
9378 // Slice for the results.
94- var results []Result
79+ var r []Result
9580
9681 // Simulate an amount of time for the search.
9782 time .Sleep (time .Millisecond * time .Duration (rand .Int63n (900 )))
9883
9984 // Simulate a result for the search.
100- results = append (results , Result {
85+ r = append (r , Result {
10186 Engine : "Yahoo" ,
10287 Title : "Go Playground" ,
10388 Description : "The Go Playground is a web service that runs on golang.org's servers" ,
10489 Link : "http://play.golang.org/" ,
10590 })
10691
107- log .Printf ("Yahoo : Search : Completed : Found[%d]\n " , len (results ))
108- searchResults <- results
92+ log .Printf ("Yahoo : Search : Completed : Found[%d]\n " , len (r ))
93+ results <- r
10994}
0 commit comments