diff --git a/README.md b/README.md index ee9d269..27311fb 100644 --- a/README.md +++ b/README.md @@ -14,48 +14,51 @@ Web feed generator library. ```go -import ( - "fmt" - "time" - "github.com/gorilla/feeds" -) +package 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{"Jason Moiron", "jmoiron@jmoiron.net"}, - Created: now, -} + import ( + "fmt" + "time" + "github.com/gorilla/feeds" + ) -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", + 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{"Jason Moiron", "jmoiron@jmoiron.net"}, 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 effectively", - 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{"Jason Moiron", "jmoiron@jmoiron.net"}, + 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 effectively", + Created: now, + }, + } + + atom, _ := feed.ToAtom() // _ parameter is err + rss, _ := feed.ToRss() // _ parameter is err + + fmt.Println(atom, "\n", rss) } -atom, err := feed.ToAtom() -rss, err := feed.ToRss() - -fmt.Println(atom, "\n", rss) - ``` Outputs: