mirror of
https://codeberg.org/librarian/feeds
synced 2024-12-06 19:16:24 +01:00
Make example program fully buildable
This commit is contained in:
@@ -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 <em>effectively</em>",
|
||||
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 <em>effectively</em>",
|
||||
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:
|
||||
|
||||
Reference in New Issue
Block a user