From 7b1a94122f4b01e5e9959e071e0f756e60332355 Mon Sep 17 00:00:00 2001 From: Jim Teeuwen Date: Thu, 28 Nov 2013 10:23:49 +0100 Subject: [PATCH] Runs go fmt on all code. --- atom.go | 12 ++++++------ feed.go | 2 +- feed_test.go | 26 +++++++++++++------------- rss.go | 2 +- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/atom.go b/atom.go index d46cb35..ccbe786 100644 --- a/atom.go +++ b/atom.go @@ -106,13 +106,13 @@ func (this *Feed) readAtom(doc *xmlx.Document) (err error) { i.Content.Base = tn.S("xml", "base") i.Content.Text = tn.GetValue() } - + if tn = item.SelectNode(ns, "author"); tn != nil { - i.Author = Author{} - i.Author.Name = tn.S(ns, "name") - i.Author.Uri = tn.S(ns, "uri") - i.Author.Email = tn.S(ns, "email") - } + i.Author = Author{} + i.Author.Name = tn.S(ns, "name") + i.Author.Uri = tn.S(ns, "uri") + i.Author.Email = tn.S(ns, "email") + } ch.Items = append(ch.Items, i) } diff --git a/feed.go b/feed.go index 71083e8..4a68c9a 100644 --- a/feed.go +++ b/feed.go @@ -165,7 +165,7 @@ func (this *Feed) makeFeed(doc *xmlx.Document) (err error) { this.CacheTimeout = this.Channels[0].TTL } - return + return } // This function returns true or false, depending on whether the CacheTimeout diff --git a/feed_test.go b/feed_test.go index 4e28eb2..fad7b7f 100644 --- a/feed_test.go +++ b/feed_test.go @@ -1,8 +1,8 @@ package feeder import ( - "testing" "io/ioutil" + "testing" ) var items []*Item @@ -31,9 +31,9 @@ func TestFeed(t *testing.T) { func Test_AtomAuthor(t *testing.T) { content, err := ioutil.ReadFile("testdata/idownload.atom") - if err != nil { + if err != nil { t.Errorf("unable to load file") - } + } feed := New(1, true, chanHandler, itemHandler) err = feed.FetchBytes("http://example.com", content, nil) @@ -45,15 +45,15 @@ func Test_AtomAuthor(t *testing.T) { } func Test_RssAuthor(t *testing.T) { - content, _ := ioutil.ReadFile("testdata/boing.rss") - feed := New(1, true, chanHandler, itemHandler) - feed.FetchBytes("http://example.com", content, nil) + content, _ := ioutil.ReadFile("testdata/boing.rss") + feed := New(1, true, chanHandler, itemHandler) + feed.FetchBytes("http://example.com", content, nil) - item := items[0] - expected := "Cory Doctorow" - if item.Author.Name != expected { - t.Errorf("Expected author to be %s but found %s", expected, item.Author.Name) - } + item := items[0] + expected := "Cory Doctorow" + if item.Author.Name != expected { + t.Errorf("Expected author to be %s but found %s", expected, item.Author.Name) + } } func Test_CData(t *testing.T) { @@ -63,7 +63,7 @@ func Test_CData(t *testing.T) { item := items[0] expected := `

abc

"def"
ghi` - if item.Description != expected { + if item.Description != expected { t.Errorf("Expected item.Description to be [%s] but item.Description=[%s]", expected, item.Description) } } @@ -73,6 +73,6 @@ func chanHandler(feed *Feed, newchannels []*Channel) { } func itemHandler(feed *Feed, ch *Channel, newitems []*Item) { - items = newitems + items = newitems println(len(newitems), "new item(s) in", ch.Title, "of", feed.Url) } diff --git a/rss.go b/rss.go index 29f2932..4ff720f 100644 --- a/rss.go +++ b/rss.go @@ -151,7 +151,7 @@ func (this *Feed) readRss2(doc *xmlx.Document) (err error) { } i.Comments = item.S(ns, "comments") - + guid := item.S(ns, "guid") if len(guid) > 0 { i.Guid = &guid