From 29bd83be4109c4fa5143b13101ea7b8b46fa6a06 Mon Sep 17 00:00:00 2001 From: Jim Teeuwen Date: Thu, 28 Nov 2013 10:22:09 +0100 Subject: [PATCH] Merge Pull Request and issue #24 Turns Item.Guid field into a string pointer, so it may properly be set to nil when applicable. Adjusts remaining code and tests to reflect this change. --- item.go | 2 +- rss.go | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/item.go b/item.go index acfeb34..c5e65fb 100644 --- a/item.go +++ b/item.go @@ -9,7 +9,7 @@ type Item struct { Categories []*Category Comments string Enclosures []*Enclosure - Guid string + Guid *string PubDate string Source *Source diff --git a/rss.go b/rss.go index 763593e..29f2932 100644 --- a/rss.go +++ b/rss.go @@ -144,15 +144,19 @@ func (this *Feed) readRss2(doc *xmlx.Document) (err error) { } if n = item.SelectNode(ns, "author"); n != nil { - i.Author = Author{} i.Author.Name = n.GetValue() - } - if n = item.SelectNode(ns, "creator"); n != nil { - i.Author = Author{ Name: n.GetValue() } + + } else if n = item.SelectNode(ns, "creator"); n != nil { + i.Author.Name = n.GetValue() } i.Comments = item.S(ns, "comments") - i.Guid = item.S(ns, "guid") + + guid := item.S(ns, "guid") + if len(guid) > 0 { + i.Guid = &guid + } + i.PubDate = item.S(ns, "pubDate") tl = item.SelectNodes(ns, "category")