Skip to content

Commit 0740565

Browse files
Fixed returns on decode calls.
1 parent 8bafc9f commit 0740565

2 files changed

Lines changed: 5 additions & 10 deletions

File tree

‎src/chapter2/search/match/feed.go‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,8 @@ func RetrieveFeed() ([]*Feed, error) {
3030
defer file.Close()
3131

3232
// Decode the file into a slice of feed values.
33+
// We don't need to check for errors, the caller can do this.
3334
var feeds []*Feed
3435
err = json.NewDecoder(file).Decode(&feeds)
35-
if err != nil {
36-
return nil, err
37-
}
38-
39-
return feeds, nil
36+
return feeds, err
4037
}

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,8 @@ func (m *rssMatcher) retrieve() (*document, error) {
125125
}
126126

127127
// Decode the rss feed document into our struct type.
128+
// We don't need to check for errors, the caller can do this.
128129
var document document
129-
if err := xml.NewDecoder(resp.Body).Decode(&document); err != nil {
130-
return nil, err
131-
}
132-
133-
return &document, nil
130+
err = xml.NewDecoder(resp.Body).Decode(&document)
131+
return &document, err
134132
}

0 commit comments

Comments
 (0)