aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorEvgeny Kuznetsov <evgeny@kuznetsov.md>2020-01-28 07:54:24 +0300
committerEvgeny Kuznetsov <evgeny@kuznetsov.md>2020-01-28 07:54:24 +0300
commit30a4cbfd963450637cd80f08b8c6b0a7c7ece92c (patch)
tree7de9f9cc2f6e978ea7c906d9b2f638b4433bc0fe /main.go
parentcf55b81a0e414b2956fec0295cd62f7f7096496b (diff)
downloadradiorus-rss-30a4cbfd963450637cd80f08b8c6b0a7c7ece92c.tar.gz
radiorus-rss-30a4cbfd963450637cd80f08b8c6b0a7c7ece92c.zip
cleaner concurrency
Diffstat (limited to 'main.go')
-rw-r--r--main.go10
1 files changed, 6 insertions, 4 deletions
diff --git a/main.go b/main.go
index ba749c5..5a2bd3e 100644
--- a/main.go
+++ b/main.go
@@ -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) {