Skip to content

Commit 8bdd92d

Browse files
committed
docs: Provide a runnable example.
1 parent c2a7af7 commit 8bdd92d

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

README.md

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
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

17-
package main {
18-
19-
import (
20-
"fmt"
21-
"time"
22-
"github.com/gorilla/feeds"
23-
)
18+
import (
19+
"fmt"
20+
"time"
21+
"github.com/gorilla/feeds"
22+
)
2423

24+
func main() {
2525
now := time.Now()
2626
feed := &feeds.Feed{
2727
Title: "jmoiron.net blog",
@@ -53,12 +53,18 @@ package main {
5353
},
5454
}
5555

56-
atom, _ := feed.ToAtom() // _ parameter is err
57-
rss, _ := feed.ToRss() // _ parameter is err
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+
}
5865

5966
fmt.Println(atom, "\n", rss)
6067
}
61-
6268
```
6369

6470
Outputs:

0 commit comments

Comments
 (0)