golang rss/atom generator library

gorilla/feeds

GoDoc CircleCI

feeds is a web feed generator library for generating RSS, Atom and JSON feeds from Go applications.

Goals

  • Provide a simple interface to create both Atom & RSS 2.0 feeds
  • Full support for Atom, RSS 2.0, and JSON Feed Version 1 spec elements
  • Ability to modify particulars for each spec

Usage

package main

import (
    "fmt"
    "log"
    "time"
    "github.com/gorilla/feeds"
)

func main() {
    now := time.Now()
    feed := &feeds.Feed{
        Title:       "jmoiron.net blog",
        Link:        &feeds.Link{Href: "http://jmoiron.net/blog"},
        Description: "discussion about tech, footie, photos",
        Author:      &feeds.Author{Name: "Jason Moiron", Email: "[email protected]"},
        Created:     now,
    }

    feed.Items = []*feeds.Item{
        &feeds.Item{
            Title:       "Limiting Concurrency in Go",
            Link:        &feeds.Link{Href: "http://jmoiron.net/blog/limiting-concurrency-in-go/"},
            Description: "A discussion on controlled parallelism in golang",
            Author:      &feeds.Author{Name: "Jason Moiron", Email: "[email protected]"},
            Created:     now,
        },
        &feeds.Item{
            Title:       "Logic-less Template Redux",
            Link:        &feeds.Link{Href: "http://jmoiron.net/blog/logicless-template-redux/"},
            Description: "More thoughts on logicless templates",
            Created:     now,
        },
        &feeds.Item{
            Title:       "Idiomatic Code Reuse in Go",
            Link:        &feeds.Link{Href: "http://jmoiron.net/blog/idiomatic-code-reuse-in-go/"},
            Description: "How to use interfaces <em>effectively</em>",
            Created:     now,
        },
    }

    atom, err := feed.ToAtom()
    if err != nil {
        log.Fatal(err)
    }

    rss, err := feed.ToRss()
    if err != nil {
        log.Fatal(err)
    }

    json, err := feed.ToJSON()
    if err != nil {
        log.Fatal(err)
    }

    fmt.Println(atom, "\n", rss, "\n", json)
}

Outputs:

<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>jmoiron.net blog</title>
  <link href="http://jmoiron.net/blog"></link>
  <id>http://jmoiron.net/blog</id>
  <updated>2013-01-16T03:26:01-05:00</updated>
  <summary>discussion about tech, footie, photos</summary>
  <entry>
    <title>Limiting Concurrency in Go</title>
    <link href="http://jmoiron.net/blog/limiting-concurrency-in-go/"></link>
    <updated>2013-01-16T03:26:01-05:00</updated>
    <id>tag:jmoiron.net,2013-01-16:/blog/limiting-concurrency-in-go/</id>
    <summary type="html">A discussion on controlled parallelism in golang</summary>
    <author>
      <name>Jason Moiron</name>
      <email>[email protected]</email>
    </author>
  </entry>
  <entry>
    <title>Logic-less Template Redux</title>
    <link href="http://jmoiron.net/blog/logicless-template-redux/"></link>
    <updated>2013-01-16T03:26:01-05:00</updated>
    <id>tag:jmoiron.net,2013-01-16:/blog/logicless-template-redux/</id>
    <summary type="html">More thoughts on logicless templates</summary>
    <author></author>
  </entry>
  <entry>
    <title>Idiomatic Code Reuse in Go</title>
    <link href="http://jmoiron.net/blog/idiomatic-code-reuse-in-go/"></link>
    <updated>2013-01-16T03:26:01-05:00</updated>
    <id>tag:jmoiron.net,2013-01-16:/blog/idiomatic-code-reuse-in-go/</id>
    <summary type="html">How to use interfaces &lt;em&gt;effectively&lt;/em&gt;</summary>
    <author></author>
  </entry>
</feed>

<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>jmoiron.net blog</title>
    <link>http://jmoiron.net/blog</link>
    <description>discussion about tech, footie, photos</description>
    <managingEditor>[email protected] (Jason Moiron)</managingEditor>
    <pubDate>2013-01-16T03:22:24-05:00</pubDate>
    <item>
      <title>Limiting Concurrency in Go</title>
      <link>http://jmoiron.net/blog/limiting-concurrency-in-go/</link>
      <description>A discussion on controlled parallelism in golang</description>
      <pubDate>2013-01-16T03:22:24-05:00</pubDate>
    </item>
    <item>
      <title>Logic-less Template Redux</title>
      <link>http://jmoiron.net/blog/logicless-template-redux/</link>
      <description>More thoughts on logicless templates</description>
      <pubDate>2013-01-16T03:22:24-05:00</pubDate>
    </item>
    <item>
      <title>Idiomatic Code Reuse in Go</title>
      <link>http://jmoiron.net/blog/idiomatic-code-reuse-in-go/</link>
      <description>How to use interfaces &lt;em&gt;effectively&lt;/em&gt;</description>
      <pubDate>2013-01-16T03:22:24-05:00</pubDate>
    </item>
  </channel>
</rss>

{
  "version": "https://jsonfeed.org/version/1",
  "title": "jmoiron.net blog",
  "home_page_url": "http://jmoiron.net/blog",
  "description": "discussion about tech, footie, photos",
  "author": {
    "name": "Jason Moiron"
  },
  "items": [
    {
      "id": "",
      "url": "http://jmoiron.net/blog/limiting-concurrency-in-go/",
      "title": "Limiting Concurrency in Go",
      "summary": "A discussion on controlled parallelism in golang",
      "date_published": "2013-01-16T03:22:24.530817846-05:00",
      "author": {
        "name": "Jason Moiron"
      }
    },
    {
      "id": "",
      "url": "http://jmoiron.net/blog/logicless-template-redux/",
      "title": "Logic-less Template Redux",
      "summary": "More thoughts on logicless templates",
      "date_published": "2013-01-16T03:22:24.530817846-05:00"
    },
    {
      "id": "",
      "url": "http://jmoiron.net/blog/idiomatic-code-reuse-in-go/",
      "title": "Idiomatic Code Reuse in Go",
      "summary": "How to use interfaces \u003cem\u003eeffectively\u003c/em\u003e",
      "date_published": "2013-01-16T03:22:24.530817846-05:00"
    }
  ]
}
Owner
Gorilla Web Toolkit
Gorilla is a web toolkit for the Go programming language that provides useful, composable packages for writing HTTP-based applications.
Gorilla Web Toolkit
Comments
  • Adding custom fields?

    Adding custom fields?

    I'm creating some custom feeds for my nissan leaf, and, I need to add fields to the rss I generate. The full spec of the tags is here. But, in a nutshell, I just need to add carwings:something tags to the feed. Here's an example -- sorry for the japanese, it's from the url above:

    <?xml version="1.0" encoding="UTF-8"?>
    <rss version="2.0" xmlns:carwings="http://www.nissan.co.jp/dtd/carwings.dtd">
      <channel>
        <title>日産WEBサイト更新情報:NISSAN Topics</title>
        <link>http://rss.nissan.co.jp/</link>
        <description>日産自動車の最新情報をお届けします。</description>
        <language>ja</language>
        <copyright>Copyright NISSAN MOTOR CO.,LTD. 2005 All Rights  Reserved.</copyright>
        <lastBuildDate>Wed, 25 Oct 2006 12:18:36 +0900</lastBuildDate>
        <docs>http://blogs.law.harvard.edu/tech/rss</docs> 
        <item>
        <title>エクストレイル X-TRAIL JAM情報更新</title>
        <carwings:readtitle>エクストレイル ジャム 情報更新</carwings:readtitle>
        <description>X-TRAIL JAM IN TOKYO DOMEのチケット一般発売開始!!</description>
        <carwings:readtext>エクストレイル ジャム 東京ドームのチケット、一般販売開始。</carwings:readtext>
        <carwings:itemimage>http://eplus.jp/sys/web/irg/2006x-trail/images/topmain.jpg</carwings:itemimage>
        <carwings:data><![CDATA[
        <body>エクストレイル<br><img src="http://lab.nissan-carwings.com/CWC/images/x-trail.jpg"></body>
        ]]>
        </carwings:data>
        <carwings:lat>35.70568</carwings:lat>
        <carwings:lon>139.75187</carwings:lon>
        <link>http://blog.nissan.co.jp/X-TRAIL/?rss</link>
        <guid>http://blog.nissan.co.jp/X-TRAIL/?rss</guid>
        <carwings:link>http://www.nissan.co.jp/EVENT/....../coupon.html</carwings:link>
        <category>コンテンツ</category>
        <pubDate>Mon, 16 Oct 2006 20:15:02 +0900</pubDate>
        </item>
      </channel>
    </rss>
    

    I'm happy to extend gorilla feeds to add the fields, but, I can't figure out an easy way to do it. Thoughts? I'd hate to have to write a new library when yours is so close!

    Thanks in advance,

    -Dave

  • Link feed field recommended, but not required for Atom and JSON feeds

    Link feed field recommended, but not required for Atom and JSON feeds

    I noticed "runtime error: invalid memory address or nil pointer dereference" while using feeds library, so i started checking the issue. It turned out that the library assumes that Feed.Link field is set although it has pointer type.

    After checking the specs: The Link field is required only for RSS feeds. Atom feeds does not require feed to contain element, but it's recommended though. JSON feed spec state that home_page_url and feed_url is optional, but strongly recommended.

    I can fix this issue for Atom and JSON feeds, but I'd like to know your opinion first.

    Would you like to keep it as it is, or to create non required fields only if Feed.Link is set?

    specs: https://validator.w3.org/feed/docs/atom.html https://jsonfeed.org/version/1

  • Atom Feed - Multiple Links

    Atom Feed - Multiple Links

    It looks like gorilla atom feeds don't support multiple links even though the atom spec does: https://tools.ietf.org/html/rfc4287#page-3

    From their example:

    <link rel="alternate" type="text/html" hreflang="en" href="http://example.org/"/>
    <link rel="self" type="application/atom+xml" href="http://example.org/feed.atom"/>
    

    I'd like to add support for this but I wanted to get feedback from the package owners first. As far as I can tell, RSS doesn't have a corresponding feature. Suggestions on your preferred approach?

  • Fails W3C feed checker

    Fails W3C feed checker

    https://validator.w3.org/feed/check.cgi

    Would be nice if the example outputs were raw files in the repo so they could be referenced by URL to various RSS feed checkers.

  • Test failure on go tip

    Test failure on go tip

    https://travis-ci.org/gorilla/feeds/jobs/55587220

    Diffs between "got" and "expected":

    diff --git a/1.txt b/2.txt
    index 4894da0..1f6f674 100644
    --- a/1.txt
    +++ b/2.txt
    @@ -1,4 +1,4 @@
    -               <?xml version="1.0" encoding="UTF-8"?><feed>
    +               <?xml version="1.0" encoding="UTF-8"?><feed xmlns="http://www.w3.org/2005/Atom">
                      <title>jmoiron.net blog</title>
                      <id>http://jmoiron.net/blog</id>
                      <updated>2013-01-16T21:52:35-05:00</updated>
    

    Do you think it's a bug in feeds, tests, or Go? I suspect these changes has something to do with it:

    • https://github.com/golang/go/commit/3be158d6ab73090a74df6bc3b7cfa062d896483a?diff=unified
    • https://go-review.googlesource.com/#/c/5910/
  • [bug] Panic when non-obligatory link field is not given to item

    [bug] Panic when non-obligatory link field is not given to item

    Describe the bug

    According to RSS 2.0 spec and the site given in README https://www.rssboard.org/rss-specification#hrelementsOfLtitemgt there is no need for link element in item. Still, if it's ommited, then the program execution results in panic. …

    Versions

    Go version: v1.19.2 package version: v1.1.1

    Steps to Reproduce

    Just do everything that is done in README code, except for links in items - do not provide them. Then run feed.toRss() and the panic should occur. …

    Expected behavior

    No panic. Or at least mention in documentation that the link is needed, although I discourage it and think it is better for package to be compatible with spec.

    Code Snippets

    package main
    
    import (
    	"fmt"
    	"github.com/gorilla/feeds"
    	"log"
    	"time"
    )
    
    func main() {
    	now := time.Now()
    	feed := &feeds.Feed{
    		Title:       "jmoiron.net blog",
    		Link:        &feeds.Link{Href: "http://jmoiron.net/blog"},
    		Description: "discussion about tech, footie, photos",
    		Author:      &feeds.Author{Name: "Jason Moiron", Email: "[email protected]"},
    		Created:     now,
    	}
    
    	feed.Items = []*feeds.Item{
    		&feeds.Item{
    			Title:       "Limiting Concurrency in Go",
    			Description: "A discussion on controlled parallelism in golang",
    			Author:      &feeds.Author{Name: "Jason Moiron", Email: "[email protected]"},
    			Created:     now,
    		},
    		&feeds.Item{
    			Title:       "Logic-less Template Redux",
    			Description: "More thoughts on logicless templates",
    			Created:     now,
    		},
    		&feeds.Item{
    			Title:       "Idiomatic Code Reuse in Go",
    			Description: "How to use interfaces <em>effectively</em>",
    			Created:     now,
    		},
    	}
    
    	rss, err := feed.ToRss()
    	if err != nil {
    		log.Fatal(err)
    	}
    
    	fmt.Println(rss)
    }
    
    

  • Sort feed items by created timestamp

    Sort feed items by created timestamp

    I have a use case where the items have the correct created timestamp but I get them as an unordered list. Would it make sense to include a helper function to sort the items in a feed by a key or would that be out of scope?

    The use case would be to apply this before calling ToRss() if needed.

  • Rss comment

    Rss comment

    Hi, first: congrats ! I'm using Gorilla as base for my own framework (https://github.com/kwiscale) and I'm using gorilla/feeds in my web blog (https://www.metal3d.org/feed/rss and https://www.metal3d.org/feed/atom). I wanted to add "comments" from my blogpost in RSS items, I see that RssItem struct has Comments property: https://github.com/gorilla/feeds/blob/master/rss.go#L69

    But I really don't see how to use them. If there is a good practice or if this field is a work in progress.

    Can you tell us more ?

    Thanks !

  • Support plural categories in an entry

    Support plural categories in an entry

    There might be multiple categories for each RSS/Atom. This PR changes the Category to an array and outputs multiple category tags.

    Ref: https://validator.w3.org/feed/docs/rss2.html

    category | Specify one or more categories that the channel belongs to. Follows the same rules as the <item>-level category element. More info.
    
  • support added for Source field in RSS

    support added for Source field in RSS

    This is a very small change, but allows a legacy iOS application I am a server for to be able to digest the RSS coming from my server, since the iOS app demands that item field Source exists on the server side.

  • Consuming feeds

    Consuming feeds

    Consuming feeds

    It is great that the feeds package makes generating atom and rss feeds easy. But there are times where you want to consume. I've searched for other libraries that support consumming atom or rss, but none really exist in the Go-o-sphere. So I thought to create a small spike to see how much work it would be. Since most xml meta data is already set it should be quite easy to implement.

    what I did

    • Added the missing xml meta data to a few typed child entities
    • Added the DownloadAtomFeed and ParseAtomFeed methods
    • Added tests to make sure it is working as expected
    • I only touched the atom code

    what is next

    • Not all meta data is added
    • Atom Link entity in feed and entry have a single relation and should be a list according to the specs
    • Investigate the rss feed

    Before I continue with my work I would like to discuss if this feature is inline with the pictured roadmap and if so, that I'm on the right direction.

  • [feature] Allow multiple Links in a feed item

    [feature] Allow multiple Links in a feed item

    Is your feature request related to a problem? Please describe.

    I would like to have the option to add multiple links to a feed item

    Describe the solution you'd like

    The Link property of a feed should rather be an array of Links. Similar like here: https://github.com/gorilla/feeds/compare/master...ratzrattillo:feeds:master

    Describe alternatives you've considered

    I have the following workaround in place just for Atom Feeds (However i am not a good Go programmer)

  • [bug] slice bounds out of range [-1:]

    [bug] slice bounds out of range [-1:]

    I started with a simple example:

    ttt := make([]*feeds.Item, 0, len(items))
    for _, r := range items {
        tt := feeds.Item{
    	Id: fmt.Sprintf("%d", r.RequestID),
        }
        ttt = append(ttt, &tt)
    }       
    now := time.Now()
    feed := &feeds.Feed{
        Title:       "sfdsdfd.net blog",
        Link:        &feeds.Link{Href: "http://sdfsdfd.net/blog"},
        Description: "discussion about tech, footie, photos",
        Author:      &feeds.Author{Name: "Jassdfdsdfdon sdfsdf", Email: "[email protected]"},
        Created:     now,
        Items:       ttt,
    }
    
    atom, err := feed.ToAtom()
    if err != nil {
        render.Render(w, r, httperr.ErrInternalServer(err.Error()))
    }
    render.PlainText(w, r, atom)
    

    At the command atom, err := feed.ToAtom() I get the following error:

    http: panic serving [::1]:39096: runtime error: slice bounds out of range [-1:] goroutine 50 [running]: net/http.(*conn).serve.func1() /usr/lib/go-1.18/src/net/http/server.go:1825 +0x148 panic({0xb99300, 0xc0002928b8}) /usr/lib/go-1.18/src/runtime/panic.go:844 +0x25a github.com/go-chi/chi/middleware.prettyStack.decorateFuncCallLine({}, {0xc0002c7a69, 0x1b}, 0x1, 0x8) /home/emaborsa/go/pkg/mod/github.com/go-chi/[email protected]/middleware/recoverer.go:130 +0x737 github.com/go-chi/chi/middleware.prettyStack.decorateLine({}, {0xc0002c7a69, 0x1b}, 0x1, 0x8) /home/emaborsa/go/pkg/mod/github.com/go-chi/[email protected]/middleware/recoverer.go:106 +0x21c github.com/go-chi/chi/middleware.prettyStack.parse({}, {0xc00049c000, 0x168e, 0x2000}, {0xb54440, 0xeb2380}) /home/emaborsa/go/pkg/mod/github.com/go-chi/[email protected]/middleware/recoverer.go:89 +0x8fa github.com/go-chi/chi/middleware.PrintPrettyStack({0xb54440, 0xeb2380}) /home/emaborsa/go/pkg/mod/github.com/go-chi/[email protected]/middleware/recoverer.go:46 +0x89 github.com/go-chi/chi/middleware.(*defaultLogEntry).Panic(0xc000290900, {0xb54440, 0xeb2380}, {0xc000498000, 0x1518, 0x2000}) /home/emaborsa/go/pkg/mod/github.com/go-chi/[email protected]/middleware/logger.go:165 +0x45 github.com/go-chi/chi/middleware.Recoverer.func1.1() /home/emaborsa/go/pkg/mod/github.com/go-chi/[email protected]/middleware/recoverer.go:28 +0x15f panic({0xb54440, 0xeb2380}) /usr/lib/go-1.18/src/runtime/panic.go:844 +0x25a github.com/gorilla/feeds.newAtomEntry(0xc000494000) /home/emaborsa/go/pkg/mod/github.com/gorilla/[email protected]/atom.go:113 +0x657 github.com/gorilla/feeds.(*Atom).AtomFeed(0xc000286018) /home/emaborsa/go/pkg/mod/github.com/gorilla/[email protected]/atom.go:156 +0x5f1 github.com/gorilla/feeds.(*Atom).FeedXml(0xc000286018) /home/emaborsa/go/pkg/mod/github.com/gorilla/[email protected]/atom.go:163 +0x29 github.com/gorilla/feeds.ToXML({0xc2f1e0, 0xc000286018}) /home/emaborsa/go/pkg/mod/github.com/gorilla/[email protected]/feed.go:78 +0x5d github.com/gorilla/feeds.(*Feed).ToAtom(0xc0002b00b0) /home/emaborsa/go/pkg/mod/github.com/gorilla/[email protected]/feed.go:104 +0x99 github.com/HGV/guest-requests-api/app.Application.GetHGVRequests({{{0xc0001bc3f0}, {0xc0001bc3f0}}}, {0x7f8c1d8b8c78, 0xc0002b2200}, 0xc0002d2500) /home/emaborsa/code/guest-requests-api/app/hgv_requests.go:120 +0xb65 net/http.HandlerFunc.ServeHTTP(0xc00000eca8, {0x7f8c1d8b8c78, 0xc0002b2200}, 0xc0002d2500) /usr/lib/go-1.18/src/net/http/server.go:2084 +0x43 github.com/go-chi/chi/v5.(*Mux).routeHTTP(0xc000092de0, {0x7f8c1d8b8c78, 0xc0002b2200}, 0xc0002d2500) /home/emaborsa/go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:442 +0x27e net/http.HandlerFunc.ServeHTTP(0xc000021bb0, {0x7f8c1d8b8c78, 0xc0002b2200}, 0xc0002d2500) /usr/lib/go-1.18/src/net/http/server.go:2084 +0x43 github.com/go-chi/chi/v5.(*Mux).ServeHTTP(0xc000092de0, {0x7f8c1d8b8c78, 0xc0002b2200}, 0xc0002d2500) /home/emaborsa/go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:71 +0xfa github.com/go-chi/chi/v5.(*Mux).Mount.func1({0x7f8c1d8b8c78, 0xc0002b2200}, 0xc0002d2500) /home/emaborsa/go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:314 +0x204 net/http.HandlerFunc.ServeHTTP(0xc00007ffc0, {0x7f8c1d8b8c78, 0xc0002b2200}, 0xc0002d2500) /usr/lib/go-1.18/src/net/http/server.go:2084 +0x43 github.com/go-chi/chi/v5.(*Mux).routeHTTP(0xc000092d80, {0x7f8c1d8b8c78, 0xc0002b2200}, 0xc0002d2500) /home/emaborsa/go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:442 +0x27e net/http.HandlerFunc.ServeHTTP(0xc000021bd0, {0x7f8c1d8b8c78, 0xc0002b2200}, 0xc0002d2500) /usr/lib/go-1.18/src/net/http/server.go:2084 +0x43 github.com/go-chi/chi/v5.(*Mux).ServeHTTP(0xc000092d80, {0x7f8c1d8b8c78, 0xc0002b2200}, 0xc0002d2500) /home/emaborsa/go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:71 +0xfa github.com/go-chi/chi/v5.(*Mux).Mount.func1({0x7f8c1d8b8c78, 0xc0002b2200}, 0xc0002d2500) /home/emaborsa/go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:314 +0x204 net/http.HandlerFunc.ServeHTTP(0xc00007ffe0, {0x7f8c1d8b8c78, 0xc0002b2200}, 0xc0002d2500) /usr/lib/go-1.18/src/net/http/server.go:2084 +0x43 github.com/go-chi/chi/v5.(*Mux).routeHTTP(0xc000092c00, {0x7f8c1d8b8c78, 0xc0002b2200}, 0xc0002d2500) /home/emaborsa/go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:442 +0x27e net/http.HandlerFunc.ServeHTTP(0xc000021b10, {0x7f8c1d8b8c78, 0xc0002b2200}, 0xc0002d2500) /usr/lib/go-1.18/src/net/http/server.go:2084 +0x43 github.com/go-chi/chi/middleware.Timeout.func1.1({0x7f8c1d8b8c78, 0xc0002b2200}, 0xc0002d2500) /home/emaborsa/go/pkg/mod/github.com/go-chi/[email protected]/middleware/timeout.go:45 +0x1fe net/http.HandlerFunc.ServeHTTP(0xc00007ff40, {0x7f8c1d8b8c78, 0xc0002b2200}, 0xc0002d2400) /usr/lib/go-1.18/src/net/http/server.go:2084 +0x43 github.com/go-chi/chi/middleware.Recoverer.func1({0x7f8c1d8b8c78, 0xc0002b2200}, 0xc0002d2400) /home/emaborsa/go/pkg/mod/github.com/go-chi/[email protected]/middleware/recoverer.go:37 +0xf8 net/http.HandlerFunc.ServeHTTP(0xc00000eab0, {0x7f8c1d8b8c78, 0xc0002b2200}, 0xc0002d2400) /usr/lib/go-1.18/src/net/http/server.go:2084 +0x43 github.com/go-chi/chi/middleware.RequestLogger.func1.1({0xc33370, 0xc0002b40e0}, 0xc0002d2300) /home/emaborsa/go/pkg/mod/github.com/go-chi/[email protected]/middleware/logger.go:57 +0x266 net/http.HandlerFunc.ServeHTTP(0xc0001fa750, {0xc33370, 0xc0002b40e0}, 0xc0002d2300) /usr/lib/go-1.18/src/net/http/server.go:2084 +0x43 github.com/go-chi/chi/middleware.RealIP.func1({0xc33370, 0xc0002b40e0}, 0xc0002d2300) /home/emaborsa/go/pkg/mod/github.com/go-chi/[email protected]/middleware/realip.go:34 +0xac net/http.HandlerFunc.ServeHTTP(0xc00000eac8, {0xc33370, 0xc0002b40e0}, 0xc0002d2300) /usr/lib/go-1.18/src/net/http/server.go:2084 +0x43 github.com/go-chi/chi/middleware.RequestID.func1({0xc33370, 0xc0002b40e0}, 0xc0002d2200) /home/emaborsa/go/pkg/mod/github.com/go-chi/[email protected]/middleware/request_id.go:76 +0x25f net/http.HandlerFunc.ServeHTTP(0xc00000eae0, {0xc33370, 0xc0002b40e0}, 0xc0002d2200) /usr/lib/go-1.18/src/net/http/server.go:2084 +0x43 github.com/go-chi/chi/v5.(*Mux).ServeHTTP(0xc000092c00, {0xc33370, 0xc0002b40e0}, 0xc0002d2200) /home/emaborsa/go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:88 +0x288 net/http.serverHandler.ServeHTTP({0xc0001dc1c0}, {0xc33370, 0xc0002b40e0}, 0xc0002d2100) /usr/lib/go-1.18/src/net/http/server.go:2916 +0x474 net/http.(*conn).serve(0xc0002f6000, {0xc33860, 0xc0002b20c0}) /usr/lib/go-1.18/src/net/http/server.go:1966 +0x193c created by net/http.(*Server).Serve /usr/lib/go-1.18/src/net/http/server.go:3071 +0x9cf

  • [bug] Sending deprecated Content-Type header

    [bug] Sending deprecated Content-Type header

    Describe the bug

    Currenly Gorilla outputs the Content-Type header as "application/xml". According to the RSS Standard Board, the correct Content-Type should be "application/rss+xml".

    Versions

    go version go1.17.5 linux/amd64 github.com/gorilla/feeds v1.1.1

    Steps to Reproduce

    $ curl -s -D - -o /dev/null http://localhost:8000/rss
    HTTP/1.1 200 OK
    Content-Type: application/xml
    Date: Fri, 18 Mar 2022 13:51:01 GMT
    Transfer-Encoding: chunked
    

    Expected behavior

    $ curl -s -D - -o /dev/null http://localhost:8000/rss
    HTTP/1.1 200 OK
    Content-Type: application/rss+xml
    Date: Fri, 18 Mar 2022 13:51:01 GMT
    Transfer-Encoding: chunked
    
  • [feature] Support JSON feed v1.1

    [feature] Support JSON feed v1.1

    Is your feature request related to a problem? Please describe. The JSON feed spec is currently at v1.1. The changes from v1.0 to v1.1 are very minor, so this should be a pretty easy box to check off.

    Describe the solution you'd like Here's a synopsis of changes, taken from the specification:

    Version 1.1 — 8/7/2020:

    • Updated to use more specific application/feed+json MIME type.
    • Added authors field to allow more than 1 author per feed or item. Deprecated author.
    • Added language field.
    • Clarified that id should be a string.
    • Updated links to JSON and other specs.
  • Don't create an empty <summary> in Atom feeds

    Don't create an empty in Atom feeds

    When creating an AtomEntry from an Item, only set Summary if item.Description is non-empty, like we already do for Content.

    Currently we always emit a <summary> element, even if the item has a non-empty <content> element. Having an empty <summary> in this case may be confusing for feed consumers.

    The Atom RFC explicitly says that a <summary> is not required in general. (There are a couple special cases where it is required, but they aren't relevant here.)

    https://tools.ietf.org/html/rfc4287#section-4.1.1.1

    Fixes #82

  • Spurious empty <summary> elements in atom feed

    Spurious empty elements in atom feed

    I have a feed in which items have a non-empty Content but an empty Description. This should result in an atom feed with a <content> element for the item but no <summary> element, but it seems that the feeds package always emits a <summary> element, even if it is empty.

    https://play.golang.org/p/gE3aNOkeIqb

    The feeds package should not should not emit a <summary> element if Item.Content is set but Item.Description is blank. Its presence may mislead feed readers into displaying the (empty) summary, ignoring the post content.

    I'm currently working around the issue like this, but would prefer if this wasn't necessary.

    atomFeed := (&feeds.Atom{feed}).AtomFeed()
    for i := range atomFeed.Entries {
    	atomFeed.Entries[i].Summary = nil
    }
    

    Versions

    Go version: go version go1.14.3 linux/amd64 package version: 6f6e20dd3953594cd869cf981fb806440685cd21

    Steps to Reproduce

    How can the bug be triggered?

    See code snippet below.

    Output:
    <?xml version="1.0" encoding="UTF-8"?><feed xmlns="http://www.w3.org/2005/Atom">
      <title>A blog</title>
      <id>http://example.net/</id>
      <updated>2009-11-10T23:00:00Z</updated>
      <link href="http://example.net/"></link>
      <author>
        <name>Test User</name>
        <email>[email protected]</email>
      </author>
      <entry>
        <title>Blog post</title>
        <updated>2009-11-10T23:00:00Z</updated>
        <id>tag:example.net,2009-11-10:/1</id>
        <content type="html">Full contents of the blog post</content>
        <link href="http://example.net/1" rel="alternate"></link>
        <summary type="html"></summary>
        <author>
          <name>Test User</name>
          <email>[email protected]</email>
        </author>
      </entry>
    </feed>
    

    Expected behavior

    What output or behaviour were you expecting instead?

    Expected output
    <?xml version="1.0" encoding="UTF-8"?><feed xmlns="http://www.w3.org/2005/Atom">
      <title>A blog</title>
      <id>http://example.net/</id>
      <updated>2009-11-10T23:00:00Z</updated>
      <link href="http://example.net/"></link>
      <author>
        <name>Test User</name>
        <email>[email protected]</email>
      </author>
      <entry>
        <title>Blog post</title>
        <updated>2009-11-10T23:00:00Z</updated>
        <id>tag:example.net,2009-11-10:/1</id>
        <content type="html">Full contents of the blog post</content>
        <link href="http://example.net/1" rel="alternate"></link>
        <author>
          <name>Test User</name>
          <email>[email protected]</email>
        </author>
      </entry>
    </feed>
    

    Code Snippets

    https://play.golang.org/p/gE3aNOkeIqb

    package main
    
    import (
    	"log"
    	"os"
    	"time"
    
    	"github.com/gorilla/feeds"
    )
    
    func main() {
    	now := time.Now()
    	feed := &feeds.Feed{
    		Title:   "A blog",
    		Link:    &feeds.Link{Href: "http://example.net/"},
    		Author:  &feeds.Author{Name: "Test User", Email: "[email protected]"},
    		Created: now,
    	}
    
    	feed.Items = []*feeds.Item{
    		&feeds.Item{
    			Title:   "Blog post",
    			Link:    &feeds.Link{Href: "http://example.net/1"},
    			Content: "Full contents of the blog post",
    			Author:  &feeds.Author{Name: "Test User", Email: "[email protected]"},
    			Created: now,
    		},
    	}
    
    	err := feed.WriteAtom(os.Stdout)
    	if err != nil {
    		log.Fatal(err)
    	}
    }
    
Svenska-yle-rss-content-fixer - Attach content to Svenska Yle RSS feeds

svenska-yle-rss-content-fixer This little tool attaches article content to the S

Oct 4, 2022
iTunes and RSS 2.0 Podcast Generator in Golang

podcast Package podcast generates a fully compliant iTunes and RSS 2.0 podcast feed for GoLang using a simple API. Full documentation with detailed ex

Dec 23, 2022
This command line converts thuderbird's exported RSS .eml file to .html file

thunderbird-rss-html This command line tool converts .html to .epub with images fetching. Install > go get github.com/gonejack/thunderbird-rss-html Us

Dec 15, 2021
Colored RSS feeds in your console

RSS Console Feed Read colored rss feeds in your console Usage ./rss-console-feed

Dec 22, 2021
Watches container registries for new and changed tags and creates an RSS feed for detected changes.

Tagwatch Watches container registries for new and changed tags and creates an RSS feed for detected changes. Configuration Tagwatch is configured thro

Jan 7, 2022
A codename generator meant for naming software releases.

codename-generator This library written in Golang generates a random code name meant for naming software releases if you run short of inspiration. Cur

Jun 26, 2022
Lorem Ipsum Generator

Generate lorem ipsum for your project. ============= Usage import "lorem" Ranged generators These will generate a string with a variable number of ele

Jul 28, 2022
🚩 TOC, zero configuration table of content generator for Markdown files, create table of contents from any Markdown file with ease.
🚩 TOC, zero configuration table of content generator for Markdown files, create table of contents from any Markdown file with ease.

toc toc TOC, table of content generator for Markdown files Table of Contents Table of Contents Usage Installation Packages Arch Linux Homebrew Docker

Dec 29, 2022
Go XML sitemap and sitemap index generator

Install go get github.com/turk/go-sitemap Example for sitemapindex func () main(c *gin.Context) { s := sitemap.NewSitemapIndex(c.Writer, true)

Jun 29, 2022
GR 4 - Wow class generator

Wow class generator Simple generator to create maps in Go using warcraft logs for Class and Spec Names. It generates : A dict of current wow classes a

Nov 5, 2021
Simple text-to-ascii-art generator

Simple text-to-ascii-art generator

Nov 17, 2021
🧑‍💻 Go XML generator without Structs™

exml ??‍?? Go XML generator without Structs™ Package exml allows XML documents to be generated without the usage of structs or maps. It is not intende

Nov 15, 2022
[Crawler/Scraper for Golang]🕷A lightweight distributed friendly Golang crawler framework.一个轻量的分布式友好的 Golang 爬虫框架。

Goribot 一个分布式友好的轻量的 Golang 爬虫框架。 完整文档 | Document !! Warning !! Goribot 已经被迁移到 Gospider|github.com/zhshch2002/gospider。修复了一些调度问题并分离了网络请求部分到另一个仓库。此仓库会继续

Oct 29, 2022
omniparser: a native Golang ETL streaming parser and transform library for CSV, JSON, XML, EDI, text, etc.
omniparser: a native Golang ETL streaming parser and transform library for CSV, JSON, XML, EDI, text, etc.

omniparser Omniparser is a native Golang ETL parser that ingests input data of various formats (CSV, txt, fixed length/width, XML, EDI/X12/EDIFACT, JS

Jan 4, 2023
Golang HTML to plaintext conversion library

html2text Converts HTML into text of the markdown-flavored variety Introduction Ensure your emails are readable by all! Turns HTML into raw text, usef

Dec 28, 2022
:book: A Golang library for text processing, including tokenization, part-of-speech tagging, and named-entity extraction.

prose prose is a natural language processing library (English only, at the moment) in pure Go. It supports tokenization, segmentation, part-of-speech

Jan 4, 2023
yview is a lightweight, minimalist and idiomatic template library based on golang html/template for building Go web application.

wview wview is a lightweight, minimalist and idiomatic template library based on golang html/template for building Go web application. Contents Instal

Dec 5, 2021
Golang library for converting Markdown to HTML. Good documentation is included.

md2html is a golang library for converting Markdown to HTML. Install go get github.com/wallblog/md2html Example package main import( "github.com/wa

Jan 11, 2022
golang 在线预览word,excel,pdf,MarkDown(Online Preview Word,Excel,PPT,PDF,Image by Golang)
golang 在线预览word,excel,pdf,MarkDown(Online Preview Word,Excel,PPT,PDF,Image by Golang)

Go View File 在线体验地址 http://39.97.98.75:8082/view/upload (不会经常更新,保留最基本的预览功能。服务器配置较低,如果出现链接超时请等待几秒刷新重试,或者换Chrome) 目前已经完成 docker部署 (不用为运行环境烦恼) Wor

Dec 26, 2022