diff --git a/channel.go b/channel.go index 9838235..65ad4c0 100644 --- a/channel.go +++ b/channel.go @@ -57,10 +57,6 @@ func initChannel() *Channel { LastBuildDate: now, } - channel.wg.Add(1) - go channel.start() - channel.wg.Wait() - return channel } @@ -92,7 +88,13 @@ func (c *Channel) check() error { } func NewChannel() *Channel { - return initChannel() + channel := initChannel() + + channel.wg.Add(1) + go channel.start() + channel.wg.Wait() + + return channel } func (c *Channel) AddCategory(category string) { diff --git a/item.go b/item.go index 689d73b..9ff5da4 100644 --- a/item.go +++ b/item.go @@ -43,10 +43,6 @@ func initItem() *Item { PubDate: time.Now().Format(time.RFC1123Z), } - item.wg.Add(1) - go item.start() - item.wg.Wait() - return item } @@ -66,7 +62,13 @@ func (i *Item) check() error { } func NewItem() *Item { - return initItem() + item := initItem() + + item.wg.Add(1) + go item.start() + item.wg.Wait() + + return item } func (i *Item) AddCategory(category string) {