mirror of
https://codeberg.org/librarian/feeds
synced 2024-12-06 19:16:24 +01:00
update readme with usage
This commit is contained in:
@@ -2,9 +2,119 @@ Syndication (feed) generator library for golang.
|
||||
|
||||
Usage:
|
||||
|
||||
```golang
|
||||
```go
|
||||
|
||||
import "syndicate"
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
"github.com/jmoiron/syndicate"
|
||||
)
|
||||
|
||||
now := time.Now()
|
||||
feed := &Feed{
|
||||
Title: "jmoiron.net blog",
|
||||
Link: &Link{Href: "http://jmoiron.net/blog"},
|
||||
Description: "discussion about tech, footie, photos",
|
||||
Author: &Author{"Jason Moiron", "jmoiron@jmoiron.net"},
|
||||
Created: now,
|
||||
}
|
||||
|
||||
feed.Items = []*Item{
|
||||
&Item{
|
||||
Title: "Limiting Concurrency in Go",
|
||||
Link: &Link{Href: "http://jmoiron.net/blog/limiting-concurrency-in-go/"},
|
||||
Description: "A discussion on controlled parallelism in golang",
|
||||
Author: &Author{"Jason Moiron", "jmoiron@jmoiron.net"},
|
||||
Created: now,
|
||||
},
|
||||
&Item{
|
||||
Title: "Logic-less Template Redux",
|
||||
Link: &Link{Href: "http://jmoiron.net/blog/logicless-template-redux/"},
|
||||
Description: "More thoughts on logicless templates",
|
||||
Created: now,
|
||||
},
|
||||
&Item{
|
||||
Title: "Idiomatic Code Reuse in Go",
|
||||
Link: &Link{Href: "http://jmoiron.net/blog/idiomatic-code-reuse-in-go/"},
|
||||
Description: "How to use interfaces <em>effectively</em>",
|
||||
Created: now,
|
||||
},
|
||||
}
|
||||
|
||||
atom, err := feed.ToAtom()
|
||||
rss, err := feed.ToRss()
|
||||
|
||||
fmt.Println(atom, "\n", rss)
|
||||
|
||||
```
|
||||
|
||||
Outputs:
|
||||
|
||||
```xml
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<feed xmlns="http://www.w3.org/2005/Atom">
|
||||
<title>jmoiron.net blog</title>
|
||||
<link href="http://jmoiron.net/blog"></link>
|
||||
<id>http://jmoiron.net/blog</id>
|
||||
<updated>2013-01-16T03:22:24-05:00</updated>
|
||||
<summary>discussion about tech, footie, photos</summary>
|
||||
<entry>
|
||||
<title>Limiting Concurrency in Go</title>
|
||||
<link href="http://jmoiron.net/blog/limiting-concurrency-in-go/"></link>
|
||||
<updated>0001-01-01T00:00:00Z</updated>
|
||||
<id>tag:jmoiron.net,2013-01-16:/blog/limiting-concurrency-in-go/</id>
|
||||
<summary type="html">A discussion on controlled parallelism in golang</summary>
|
||||
<author>
|
||||
<name>Jason Moiron</name>
|
||||
<email>jmoiron@jmoiron.net</email>
|
||||
</author>
|
||||
</entry>
|
||||
<entry>
|
||||
<title>Logic-less Template Redux</title>
|
||||
<link href="http://jmoiron.net/blog/logicless-template-redux/"></link>
|
||||
<updated>0001-01-01T00:00:00Z</updated>
|
||||
<id>tag:jmoiron.net,2013-01-16:/blog/logicless-template-redux/</id>
|
||||
<summary type="html">More thoughts on logicless templates</summary>
|
||||
<author></author>
|
||||
</entry>
|
||||
<entry>
|
||||
<title>Idiomatic Code Reuse in Go</title>
|
||||
<link href="http://jmoiron.net/blog/idiomatic-code-reuse-in-go/"></link>
|
||||
<updated>0001-01-01T00:00:00Z</updated>
|
||||
<id>tag:jmoiron.net,2013-01-16:/blog/idiomatic-code-reuse-in-go/</id>
|
||||
<summary type="html">How to use interfaces <em>effectively</em></summary>
|
||||
<author></author>
|
||||
</entry>
|
||||
</feed>
|
||||
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<rss version="2.0">
|
||||
<channel>
|
||||
<title>jmoiron.net blog</title>
|
||||
<link>http://jmoiron.net/blog</link>
|
||||
<description>discussion about tech, footie, photos</description>
|
||||
<managingEditor>jmoiron@jmoiron.net (Jason Moiron)</managingEditor>
|
||||
<pubDate>2013-01-16T03:22:24-05:00</pubDate>
|
||||
<item>
|
||||
<title>Limiting Concurrency in Go</title>
|
||||
<link>http://jmoiron.net/blog/limiting-concurrency-in-go/</link>
|
||||
<description>A discussion on controlled parallelism in golang</description>
|
||||
<pubDate>2013-01-16T03:22:24-05:00</pubDate>
|
||||
</item>
|
||||
<item>
|
||||
<title>Logic-less Template Redux</title>
|
||||
<link>http://jmoiron.net/blog/logicless-template-redux/</link>
|
||||
<description>More thoughts on logicless templates</description>
|
||||
<pubDate>2013-01-16T03:22:24-05:00</pubDate>
|
||||
</item>
|
||||
<item>
|
||||
<title>Idiomatic Code Reuse in Go</title>
|
||||
<link>http://jmoiron.net/blog/idiomatic-code-reuse-in-go/</link>
|
||||
<description>How to use interfaces <em>effectively</em></description>
|
||||
<pubDate>2013-01-16T03:22:24-05:00</pubDate>
|
||||
</item>
|
||||
</channel>
|
||||
</rss>
|
||||
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user