Either I am losing my mind, I don't understand arrays of pointers, or the library is busted. Perhaps you can help. The following code seems to fetch Atom items just fine, but viewing their titles are coming back as empty strings.
(This happens to be implemented via http, I don't think that's the problem but of course anything's possible.)
package main
import (
"fmt"
rss "github.com/jteeuwen/go-pkg-rss"
"net/http"
"os"
)
var items []*rss.Item
var channels []*rss.Channel
func hello(w http.ResponseWriter, r *http.Request) {
feed := rss.New(5, true, chanHandler, itemHandler)
url := "http://stackoverflow.com/feeds"
feed.Fetch(url, nil)
fmt.Printf("Sent fetch for %s
", url)
fmt.Fprintf(w, "There are %d items in %s
", len(items), url)
for key, value := range items {
fmt.Fprintf(w, "%d: %s
", key, value.Title)
}
}
func main() {
http.HandleFunc("/", hello)
http.ListenAndServe(":"+os.Getenv("PORT"), nil)
}
func chanHandler(feed *rss.Feed, newchannels []*rss.Channel) {
channels = newchannels
}
func itemHandler(feed *rss.Feed, ch *rss.Channel, newitems []*rss.Item) {
items = newitems
}