diff options
author | Evgeny Kuznetsov <evgeny@kuznetsov.md> | 2020-01-28 07:54:24 +0300 |
---|---|---|
committer | Evgeny Kuznetsov <evgeny@kuznetsov.md> | 2020-01-28 07:54:24 +0300 |
commit | 30a4cbfd963450637cd80f08b8c6b0a7c7ece92c (patch) | |
tree | 7de9f9cc2f6e978ea7c906d9b2f638b4433bc0fe /main.go | |
parent | cf55b81a0e414b2956fec0295cd62f7f7096496b (diff) | |
download | radiorus-rss-30a4cbfd963450637cd80f08b8c6b0a7c7ece92c.tar.gz radiorus-rss-30a4cbfd963450637cd80f08b8c6b0a7c7ece92c.zip |
cleaner concurrency
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -70,8 +70,7 @@ func main() { var wg sync.WaitGroup wg.Add(1) go describeFeed(feed, &wg) - wg.Add(len(feed.Items)) - go describeEpisodes(feed, &wg) + describeEpisodes(feed) feed.Created = time.Now() wg.Wait() @@ -161,10 +160,13 @@ func describeFeed(feed *feeds.Feed, wg *sync.WaitGroup) { feed.Description = string(re.ReplaceAll(programAbout, []byte(``))) } -func describeEpisodes(feed *feeds.Feed, wg *sync.WaitGroup) { +func describeEpisodes(feed *feeds.Feed) { + var wg sync.WaitGroup for _, item := range feed.Items { - go describeEpisode(item, wg) + wg.Add(1) + go describeEpisode(item, &wg) } + wg.Wait() } func describeEpisode(item *feeds.Item, wg *sync.WaitGroup) { |