I have the eclipse software ready to go
.
What I am looking for is to debug output the return data for calling search.RetrieveFeeds()
.
So, in essence, I'd be able to see an array of Feed structs so i know it processed the json data file
When I execute I get this error:
main\main.go:10:38: multiple-value search.RetrieveFeeds() in single-value context
I looked here: Multiple values in single-value context but it was a bit over my head.
Here is what I have so far as my architecture:
Data Json File Path
src/data/data.json
Data for Json File
[
{
"site": "npr",
"link": "http://www.npr.org/rss/rss.php?id=1001",
"type": "rss"
},
{
"site": "cnn",
"link": "http://rss.cnn.com/rss/cnn_world.rss",
"type": "rss"
},
{
"site": "foxnews",
"link": "http://feeds.foxnews.com/foxnews/world?format=xml",
"type": "rss"
},
{
"site": "nbcnews",
"link": "http://feeds.nbcnews.com/feeds/topstories",
"type": "rss"
}
]
Main Method File Path
src/main/main.go
Code for Main Method
package main
import (
"fmt"
"search"
)
func main() {
fmt.Println("HellAo")
var feeds = search.RetrieveFeeds()
fmt.Printf("%v",feeds)
}
Search File Path
src/search/feed.go
Search File Code
package search
import (
"encoding/json"
"os"
)
const dataFile = "data/data.json"
type Feed struct {
Name string `json:"site"`
URI string `json:"link"`
Type string `json:"type"`
}
func RetrieveFeeds() ([]*Feed, error){
file, err := os.Open(dataFile)
if err != nil {
return nil, err
}
defer file.Close()
var feeds []*Feed
err = json.NewDecoder(file).Decode(&feeds)
return feeds, err
}
UPDATE
I changed the data json path to:
const dataFile = "src/data/data.json"
And now the debug dump says:
<nil>