Skip to content

Commit 711228e

Browse files
committed
update readme with usage
1 parent 04c746f commit 711228e

File tree

1 file changed

+112
-2
lines changed

1 file changed

+112
-2
lines changed

README.md

Lines changed: 112 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,119 @@ Syndication (feed) generator library for golang.
22

33
Usage:
44

5-
```golang
5+
```go
66

7-
import "syndicate"
7+
import (
8+
"fmt"
9+
"time"
10+
"github.com/jmoiron/syndicate"
11+
)
12+
13+
now := time.Now()
14+
feed := &Feed{
15+
Title: "jmoiron.net blog",
16+
Link: &Link{Href: "http://jmoiron.net/blog"},
17+
Description: "discussion about tech, footie, photos",
18+
Author: &Author{"Jason Moiron", "[email protected]"},
19+
Created: now,
20+
}
21+
22+
feed.Items = []*Item{
23+
&Item{
24+
Title: "Limiting Concurrency in Go",
25+
Link: &Link{Href: "http://jmoiron.net/blog/limiting-concurrency-in-go/"},
26+
Description: "A discussion on controlled parallelism in golang",
27+
Author: &Author{"Jason Moiron", "[email protected]"},
28+
Created: now,
29+
},
30+
&Item{
31+
Title: "Logic-less Template Redux",
32+
Link: &Link{Href: "http://jmoiron.net/blog/logicless-template-redux/"},
33+
Description: "More thoughts on logicless templates",
34+
Created: now,
35+
},
36+
&Item{
37+
Title: "Idiomatic Code Reuse in Go",
38+
Link: &Link{Href: "http://jmoiron.net/blog/idiomatic-code-reuse-in-go/"},
39+
Description: "How to use interfaces <em>effectively</em>",
40+
Created: now,
41+
},
42+
}
43+
44+
atom, err := feed.ToAtom()
45+
rss, err := feed.ToRss()
46+
47+
fmt.Println(atom, "\n", rss)
48+
49+
```
50+
51+
Outputs:
52+
53+
```xml
54+
<?xml version="1.0" encoding="UTF-8"?>
55+
<feed xmlns="http://www.w3.org/2005/Atom">
56+
<title>jmoiron.net blog</title>
57+
<link href="http://jmoiron.net/blog"></link>
58+
<id>http://jmoiron.net/blog</id>
59+
<updated>2013-01-16T03:22:24-05:00</updated>
60+
<summary>discussion about tech, footie, photos</summary>
61+
<entry>
62+
<title>Limiting Concurrency in Go</title>
63+
<link href="http://jmoiron.net/blog/limiting-concurrency-in-go/"></link>
64+
<updated>0001-01-01T00:00:00Z</updated>
65+
<id>tag:jmoiron.net,2013-01-16:/blog/limiting-concurrency-in-go/</id>
66+
<summary type="html">A discussion on controlled parallelism in golang</summary>
67+
<author>
68+
<name>Jason Moiron</name>
69+
<email>[email protected]</email>
70+
</author>
71+
</entry>
72+
<entry>
73+
<title>Logic-less Template Redux</title>
74+
<link href="http://jmoiron.net/blog/logicless-template-redux/"></link>
75+
<updated>0001-01-01T00:00:00Z</updated>
76+
<id>tag:jmoiron.net,2013-01-16:/blog/logicless-template-redux/</id>
77+
<summary type="html">More thoughts on logicless templates</summary>
78+
<author></author>
79+
</entry>
80+
<entry>
81+
<title>Idiomatic Code Reuse in Go</title>
82+
<link href="http://jmoiron.net/blog/idiomatic-code-reuse-in-go/"></link>
83+
<updated>0001-01-01T00:00:00Z</updated>
84+
<id>tag:jmoiron.net,2013-01-16:/blog/idiomatic-code-reuse-in-go/</id>
85+
<summary type="html">How to use interfaces &lt;em&gt;effectively&lt;/em&gt;</summary>
86+
<author></author>
87+
</entry>
88+
</feed>
89+
90+
<?xml version="1.0" encoding="UTF-8"?>
91+
<rss version="2.0">
92+
<channel>
93+
<title>jmoiron.net blog</title>
94+
<link>http://jmoiron.net/blog</link>
95+
<description>discussion about tech, footie, photos</description>
96+
<managingEditor>[email protected] (Jason Moiron)</managingEditor>
97+
<pubDate>2013-01-16T03:22:24-05:00</pubDate>
98+
<item>
99+
<title>Limiting Concurrency in Go</title>
100+
<link>http://jmoiron.net/blog/limiting-concurrency-in-go/</link>
101+
<description>A discussion on controlled parallelism in golang</description>
102+
<pubDate>2013-01-16T03:22:24-05:00</pubDate>
103+
</item>
104+
<item>
105+
<title>Logic-less Template Redux</title>
106+
<link>http://jmoiron.net/blog/logicless-template-redux/</link>
107+
<description>More thoughts on logicless templates</description>
108+
<pubDate>2013-01-16T03:22:24-05:00</pubDate>
109+
</item>
110+
<item>
111+
<title>Idiomatic Code Reuse in Go</title>
112+
<link>http://jmoiron.net/blog/idiomatic-code-reuse-in-go/</link>
113+
<description>How to use interfaces &lt;em&gt;effectively&lt;/em&gt;</description>
114+
<pubDate>2013-01-16T03:22:24-05:00</pubDate>
115+
</item>
116+
</channel>
117+
</rss>
8118

9119
```
10120

0 commit comments

Comments
 (0)