Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
74 lines (58 sloc) 2.26 KB
Syndication (feed) generator library for golang.
go get
Feeds provides a simple, generic Feed interface with a generic Item object as well as RSS, Atom and JSON Feed specific RssFeed, AtomFeed and JSONFeed objects which allow access to all of each spec's defined elements.
Create a Feed and some Items in that feed using the generic interfaces:
import (
. "
now = time.Now()
feed := &Feed{
Title: " blog",
Link: &Link{Href: ""},
Description: "discussion about tech, footie, photos",
Author: &Author{Name: "Jason Moiron", Email: ""},
Created: now,
Copyright: "This work is copyright © Benjamin Button",
feed.Items = []*Item{
Title: "Limiting Concurrency in Go",
Link: &Link{Href: ""},
Description: "A discussion on controlled parallelism in golang",
Author: &Author{Name: "Jason Moiron", Email: ""},
Created: now,
Title: "Logic-less Template Redux",
Link: &Link{Href: ""},
Description: "More thoughts on logicless templates",
Created: now,
Title: "Idiomatic Code Reuse in Go",
Link: &Link{Href: ""},
Description: "How to use interfaces <em>effectively</em>",
Created: now,
From here, you can output Atom, RSS, or JSON Feed versions of this feed easily
atom, err := feed.ToAtom()
rss, err := feed.ToRss()
json, err := feed.ToJSON()
You can also get access to the underlying objects that feeds uses to export its XML
atomFeed := (&Atom{Feed: feed}).AtomFeed()
rssFeed := (&Rss{Feed: feed}).RssFeed()
jsonFeed := (&JSON{Feed: feed}).JSONFeed()
From here, you can modify or add each syndication's specific fields before outputting
atomFeed.Subtitle = "plays the blues"
atom, err := ToXML(atomFeed)
rssFeed.Generator = "gorilla/feeds v1.0 ("
rss, err := ToXML(rssFeed)
jsonFeed.NextUrl = ""
json, err := jsonFeed.ToJSON()
package feeds