diff --git a/cmd/httpsubs/main.go b/cmd/httpsubs/main.go index 74b9d52..158c88e 100644 --- a/cmd/httpsubs/main.go +++ b/cmd/httpsubs/main.go @@ -25,7 +25,6 @@ func main() { fmt.Fprintln(os.Stderr, err) os.Exit(1) } - go subscriber.Subscribe() c := make(chan os.Signal, 1) signal.Notify(c, os.Interrupt) diff --git a/subscription.go b/subscription.go index e226d3b..b2ccea1 100644 --- a/subscription.go +++ b/subscription.go @@ -43,11 +43,13 @@ func NewHTTPSubscriber(remoteURL, localFile string, interval time.Duration) (*HT return nil, err } + go sub.subscribe() + return &sub, nil } -// Subscribe starts the subscription process. -func (s *HTTPSubscriber) Subscribe() { +// subscribe starts the subscription process. +func (s *HTTPSubscriber) subscribe() { timer := time.NewTimer(0) for { diff --git a/subscription_test.go b/subscription_test.go index e3b24ca..f8ad6dd 100644 --- a/subscription_test.go +++ b/subscription_test.go @@ -70,7 +70,6 @@ func TestHTTPSubscriber(t *testing.T) { if err != nil { t.Fatal(err) } - go subscriber.Subscribe() // Allow some time for subscription to run time.Sleep(2 * time.Second)