diff --git a/consul/discovery.go b/consul/discovery.go index fdb82df..928cd56 100644 --- a/consul/discovery.go +++ b/consul/discovery.go @@ -72,7 +72,7 @@ func (s *Service) Register() error { return err } - go func() { // startup register + go func(s *Service) { // startup register ticker := time.NewTicker(time.Millisecond * 100) for range ticker.C { ok, _ := s.healthCheck() @@ -80,9 +80,9 @@ func (s *Service) Register() error { ticker.Stop() } } - }() + }(s) - go func() { // TTL + go func(s *Service) { // TTL interval := s.ttl - time.Second*2 ticker := time.NewTicker(interval) for range ticker.C { @@ -91,7 +91,7 @@ func (s *Service) Register() error { fmt.Printf("TTL Error: %v\n", err) } } - }() + }(s) return nil }