Skip to content

Commit a6a2712

Browse files
committed
Merge pull request #23 from elithrar/virtualsue-doc-fixes
docs: Provide a runnable example.
2 parents e57da33 + 4e66b61 commit a6a2712

File tree

1 file changed

+48
-39
lines changed

1 file changed

+48
-39
lines changed

README.md

Lines changed: 48 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,70 @@
11
## gorilla/feeds
2+
[![GoDoc](https://godoc.org/github.com/gorilla/feeds?status.svg)](https://godoc.org/github.com/gorilla/feeds) [![Build Status](https://travis-ci.org/gorilla/feeds.png?branch=master)](https://travis-ci.org/gorilla/feeds)
23

3-
Web feed generator library.
4-
5-
[![Build Status](https://travis-ci.org/gorilla/feeds.png?branch=master)](https://travis-ci.org/gorilla/feeds)
4+
feeds is a web feed generator library for generating RSS and Atom feeds from Go
5+
applications.
66

77
### Goals
88

9-
* simple interface to create both Atom & RSS 2.0 feeds
10-
* full support for Atom/RSS2.0 spec elements
11-
* ability to modify particulars for each spec
9+
* Provide a simple interface to create both Atom & RSS 2.0 feeds
10+
* Full support for Atom and RSS2.0 spec elements
11+
* Ability to modify particulars for each spec
1212

1313
### Usage
1414

1515
```go
16+
package main
1617

1718
import (
1819
"fmt"
1920
"time"
2021
"github.com/gorilla/feeds"
2122
)
2223

23-
now := time.Now()
24-
feed := &feeds.Feed{
25-
Title: "jmoiron.net blog",
26-
Link: &feeds.Link{Href: "http://jmoiron.net/blog"},
27-
Description: "discussion about tech, footie, photos",
28-
Author: &feeds.Author{"Jason Moiron", "[email protected]"},
29-
Created: now,
30-
}
31-
32-
feed.Items = []*feeds.Item{
33-
&feeds.Item{
34-
Title: "Limiting Concurrency in Go",
35-
Link: &feeds.Link{Href: "http://jmoiron.net/blog/limiting-concurrency-in-go/"},
36-
Description: "A discussion on controlled parallelism in golang",
24+
func main() {
25+
now := time.Now()
26+
feed := &feeds.Feed{
27+
Title: "jmoiron.net blog",
28+
Link: &feeds.Link{Href: "http://jmoiron.net/blog"},
29+
Description: "discussion about tech, footie, photos",
3730
Author: &feeds.Author{"Jason Moiron", "[email protected]"},
3831
Created: now,
39-
},
40-
&feeds.Item{
41-
Title: "Logic-less Template Redux",
42-
Link: &feeds.Link{Href: "http://jmoiron.net/blog/logicless-template-redux/"},
43-
Description: "More thoughts on logicless templates",
44-
Created: now,
45-
},
46-
&feeds.Item{
47-
Title: "Idiomatic Code Reuse in Go",
48-
Link: &feeds.Link{Href: "http://jmoiron.net/blog/idiomatic-code-reuse-in-go/"},
49-
Description: "How to use interfaces <em>effectively</em>",
50-
Created: now,
51-
},
32+
}
33+
34+
feed.Items = []*feeds.Item{
35+
&feeds.Item{
36+
Title: "Limiting Concurrency in Go",
37+
Link: &feeds.Link{Href: "http://jmoiron.net/blog/limiting-concurrency-in-go/"},
38+
Description: "A discussion on controlled parallelism in golang",
39+
Author: &feeds.Author{"Jason Moiron", "[email protected]"},
40+
Created: now,
41+
},
42+
&feeds.Item{
43+
Title: "Logic-less Template Redux",
44+
Link: &feeds.Link{Href: "http://jmoiron.net/blog/logicless-template-redux/"},
45+
Description: "More thoughts on logicless templates",
46+
Created: now,
47+
},
48+
&feeds.Item{
49+
Title: "Idiomatic Code Reuse in Go",
50+
Link: &feeds.Link{Href: "http://jmoiron.net/blog/idiomatic-code-reuse-in-go/"},
51+
Description: "How to use interfaces <em>effectively</em>",
52+
Created: now,
53+
},
54+
}
55+
56+
atom, err := feed.ToAtom()
57+
if err != nil {
58+
log.Fatal(err)
59+
}
60+
61+
rss, err := feed.ToRss()
62+
if err != nil {
63+
log.Fatal(err)
64+
}
65+
66+
fmt.Println(atom, "\n", rss)
5267
}
53-
54-
atom, err := feed.ToAtom()
55-
rss, err := feed.ToRss()
56-
57-
fmt.Println(atom, "\n", rss)
58-
5968
```
6069

6170
Outputs:

0 commit comments

Comments
 (0)