File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77
88// main is the entry point for the program.
99func main () {
10- // Perform the search.
10+ // Perform the search for the specified term .
1111 search .Run ("president" )
1212}
Original file line number Diff line number Diff line change 5656// rssMatcher implements the Matcher interface.
5757type rssMatcher struct {}
5858
59- // init registered the matcher with the program
59+ // init registeres the matcher with the program.
6060func init () {
6161 search .Register ("rss" , & rssMatcher {})
6262}
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ package search
33// defaultMatcher implements the defaut matcher.
44type defaultMatcher struct {}
55
6- // init registered the matcher with the program
6+ // init registeres the default matcher with the program.
77func init () {
88 Register ("default" , & defaultMatcher {})
99}
Original file line number Diff line number Diff line change @@ -16,8 +16,7 @@ type Feed struct {
1616 Type string `json:"type"`
1717}
1818
19- // RetrieveFeed reads and unmarshals the feed data file
20- // into a native slice for use.
19+ // RetrieveFeed reads and unmarshals the feed data file.
2120func RetrieveFeed () ([]* Feed , error ) {
2221 // Open the file.
2322 file , err := os .Open (dataFile )
@@ -29,9 +28,11 @@ func RetrieveFeed() ([]*Feed, error) {
2928 // the function returns.
3029 defer file .Close ()
3130
32- // Decode the file into a slice of feed values.
33- // We don't need to check for errors, the caller can do this .
31+ // Decode the file into a slice of pointers
32+ // to Feed values .
3433 var feeds []* Feed
3534 err = json .NewDecoder (file ).Decode (& feeds )
35+
36+ // We don't need to check for errors, the caller can do this.
3637 return feeds , err
3738}
Original file line number Diff line number Diff line change @@ -11,7 +11,8 @@ type Result struct {
1111 Content string
1212}
1313
14- // Matcher defines the behavior required by the Search function.
14+ // Matcher defines the behavior required by types that want
15+ // to implement a new search type.
1516type Matcher interface {
1617 Search (feed * Feed , searchTerm string ) ([]* Result , error )
1718}
Original file line number Diff line number Diff line change 99 // Used to synchronize access to the matchers map.
1010 lock sync.Mutex
1111
12- // A map of registered matchers for searching
12+ // A map of registered matchers for searching.
1313 matchers map [string ]Matcher = make (map [string ]Matcher )
1414)
1515
You can’t perform that action at this time.
0 commit comments