MCPcopy Create free account
hub / github.com/goinaction/code / RetrieveFeeds

Function RetrieveFeeds

chapter2/sample/search/feed.go:18–36  ·  view source on GitHub ↗

RetrieveFeeds reads and unmarshals the feed data file.

()

Source from the content-addressed store, hash-verified

16
17// RetrieveFeeds reads and unmarshals the feed data file.
18func RetrieveFeeds() ([]*Feed, error) {
19 // Open the file.
20 file, err := os.Open(dataFile)
21 if err != nil {
22 return nil, err
23 }
24
25 // Schedule the file to be closed once
26 // the function returns.
27 defer file.Close()
28
29 // Decode the file into a slice of pointers
30 // to Feed values.
31 var feeds []*Feed
32 err = json.NewDecoder(file).Decode(&feeds)
33
34 // We don't need to check for errors, the caller can do this.
35 return feeds, err
36}

Callers 1

RunFunction · 0.85

Calls 2

OpenMethod · 0.80
CloseMethod · 0.45

Tested by

no test coverage detected