parallelize fetching feeds
This commit is contained in:
parent
1b248ddbbb
commit
aa5b4923a3
|
@ -44,12 +44,21 @@ func rssfetch(cmd *cobra.Command, urls []string) {
|
|||
}
|
||||
|
||||
fp := gofeed.NewParser()
|
||||
var feedChs []chan *gofeed.Feed
|
||||
for _, url := range urls {
|
||||
ch := make(chan *gofeed.Feed)
|
||||
go func(url string) {
|
||||
feed, err := fp.ParseURL(url)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
ch <- feed
|
||||
}(url)
|
||||
feedChs = append(feedChs, ch)
|
||||
}
|
||||
|
||||
for _, feedCh := range feedChs {
|
||||
feed := <-feedCh
|
||||
for _, item := range feed.Items {
|
||||
out, err := formatItem(item, tmpl)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue