set slice lengths at creation

This commit is contained in:
filifa 2024-06-18 19:32:08 -05:00
parent 7d2d4f0960
commit 34abeeb37b
1 changed files with 9 additions and 9 deletions

View File

@ -41,10 +41,10 @@ func formatItem(item *gofeed.Item, tmpl *template.Template) (string, error) {
// along with any parsing errors.
func parseFeeds(urls []string) ([]*gofeed.Feed, []error) {
fp := gofeed.NewParser()
var feedChs []chan *gofeed.Feed
var errChs []chan error
feedChs := make([]chan *gofeed.Feed, len(urls))
errChs := make([]chan error, len(urls))
for _, url := range urls {
for i, url := range urls {
feedCh := make(chan *gofeed.Feed)
errCh := make(chan error)
go func(url string) {
@ -52,15 +52,15 @@ func parseFeeds(urls []string) ([]*gofeed.Feed, []error) {
feedCh <- feed
errCh <- err
}(url)
feedChs = append(feedChs, feedCh)
errChs = append(errChs, errCh)
feedChs[i] = feedCh
errChs[i] = errCh
}
var feeds []*gofeed.Feed
var errs []error
feeds := make([]*gofeed.Feed, len(urls))
errs := make([]error, len(urls))
for i := range feedChs {
feeds = append(feeds, <-feedChs[i])
errs = append(errs, <-errChs[i])
feeds[i] = <-feedChs[i]
errs[i] = <-errChs[i]
}
return feeds, errs