Skip to content

Commit 1e10844

Browse files
committed
Reverted Load to returning []Feed rather than []*Feed
1 parent 1bb1398 commit 1e10844

4 files changed

Lines changed: 10 additions & 12 deletions

File tree

‎src/chapter2/search/data.go‎

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,15 @@ const (
99
dataFile = "data/data.json"
1010
)
1111

12-
type (
13-
// Feed contains information about an rss feed.
14-
Feed struct {
15-
Name string `json:"site"`
16-
Uri string `json:"link"`
17-
Type string `json:"type"`
18-
}
19-
)
12+
// Feed contains information about an rss feed.
13+
type Feed struct {
14+
Name string `json:"site"`
15+
Uri string `json:"link"`
16+
Type string `json:"type"`
17+
}
2018

2119
// Load retrieves and unmarshals the data for the program.
22-
func Load() ([]*Feed, error) {
20+
func Load() ([]Feed, error) {
2321
// Open the file.
2422
file, err := os.Open(dataFile)
2523
if err != nil {
@@ -31,7 +29,7 @@ func Load() ([]*Feed, error) {
3129
defer file.Close()
3230

3331
// Decode the file into a slice of feed values.
34-
var feeds []*Feed
32+
var feeds []Feed
3533
err = json.NewDecoder(file).Decode(&feeds)
3634
if err != nil {
3735
return nil, err

‎src/chapter2/search/main.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77

88
// NewMatcher is a factory that creates matcher values based
99
// on the type of feed specified.
10-
func NewMatcher(feed *Feed) Matcher {
10+
func NewMatcher(feed Feed) Matcher {
1111
// Create the right type of matcher for this search.
1212
switch feed.Type {
1313
case "rss":

‎src/chapter2/search/rss.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ type (
5353

5454
// rssMatcher implements the Matcher interface.
5555
type rssMatcher struct {
56-
*Feed
56+
Feed
5757
}
5858

5959
// Match looks at the document for the specified search term.

‎src/chapter2/search/search‎

80 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)