Skip to content

Commit 338f576

Browse files
Fixed private function and comments
1 parent c6a1249 commit 338f576

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

  • chapter2/sample/matchers

‎chapter2/sample/matchers/rss.go‎

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import (
1212
)
1313

1414
type (
15-
// item defines the fields associated with the item tag in the rss document.
15+
// item defines the fields associated with the item tag
16+
// in the rss document.
1617
item struct {
1718
XMLName xml.Name `xml:"item"`
1819
PubDate string `xml:"pubDate"`
@@ -23,15 +24,17 @@ type (
2324
GeoRssPoint string `xml:"georss:point"`
2425
}
2526

26-
// image defines the fields associated with the image tag in the rss document.
27+
// image defines the fields associated with the image tag
28+
// in the rss document.
2729
image struct {
2830
XMLName xml.Name `xml:"image"`
2931
URL string `xml:"url"`
3032
Title string `xml:"title"`
3133
Link string `xml:"link"`
3234
}
3335

34-
// channel defines the fields associated with the channel tag in the rss document.
36+
// channel defines the fields associated with the channel tag
37+
// in the rss document.
3538
channel struct {
3639
XMLName xml.Name `xml:"channel"`
3740
Title string `xml:"title"`
@@ -47,8 +50,8 @@ type (
4750
Item []item `xml:"item"`
4851
}
4952

50-
// document defines the fields associated with the rss document.
51-
document struct {
53+
// rssDocument defines the fields associated with the rss document.
54+
rssDocument struct {
5255
XMLName xml.Name `xml:"rss"`
5356
Channel channel `xml:"channel"`
5457
}
@@ -57,14 +60,14 @@ type (
5760
// rssMatcher implements the Matcher interface.
5861
type rssMatcher struct{}
5962

60-
// init registeres the matcher with the program.
63+
// init registers the matcher with the program.
6164
func init() {
62-
var matcher *rssMatcher
65+
var matcher rssMatcher
6366
search.Register("rss", matcher)
6467
}
6568

6669
// Search looks at the document for the specified search term.
67-
func (m *rssMatcher) Search(feed *search.Feed, searchTerm string) ([]*search.Result, error) {
70+
func (m rssMatcher) Search(feed *search.Feed, searchTerm string) ([]*search.Result, error) {
6871
var results []*search.Result
6972

7073
log.Printf("Search Feed Type[%s] Site[%s] For Uri[%s]\n", feed.Type, feed.Name, feed.Uri)
@@ -109,7 +112,7 @@ func (m *rssMatcher) Search(feed *search.Feed, searchTerm string) ([]*search.Res
109112
}
110113

111114
// retrieve performs a HTTP Get request for the rss feed and decodes the results.
112-
func (m *rssMatcher) retrieve(feed *search.Feed) (*document, error) {
115+
func (m rssMatcher) retrieve(feed *search.Feed) (*rssDocument, error) {
113116
if feed.Uri == "" {
114117
return nil, errors.New("No rss feed uri provided")
115118
}
@@ -131,7 +134,7 @@ func (m *rssMatcher) retrieve(feed *search.Feed) (*document, error) {
131134

132135
// Decode the rss feed document into our struct type.
133136
// We don't need to check for errors, the caller can do this.
134-
var document document
137+
var document rssDocument
135138
err = xml.NewDecoder(resp.Body).Decode(&document)
136139
return &document, err
137140
}

0 commit comments

Comments
 (0)