package main import ( "encoding/xml" "time" ) type Document struct { Channel Channel `xml:"channel"` } type Item struct { Title string `xml:"title"` Link string `xml:"link"` Description string `xml:"description"` PubDate string `xml:"pubDate"` PublishedDate time.Time } type Channel struct { Title string `xml:"title"` Description string `xml:"description"` Items []Item `xml:"item"` } const DATE_FORMAT = "Mon, 02 Jan 2006 15:04:05 -0700" func (i Item) GetPublishedDate() time.Time { published, _ := time.Parse(DATE_FORMAT, i.PubDate) return published } func ParseFeed(raw []byte) Document { var doc Document if err := xml.Unmarshal(raw, &doc); err != nil { return Document{} } return doc }