diff --git a/pkg/termination/handler.go b/pkg/termination/handler.go index 375694b2ab..bdf466d639 100644 --- a/pkg/termination/handler.go +++ b/pkg/termination/handler.go @@ -70,9 +70,9 @@ func (h *handler) Run(stop <-chan struct{}) error { errs := make(chan error, 1) wg := &sync.WaitGroup{} wg.Add(1) - go func() { - errs <- h.run(ctx, wg) - }() + go func(errChan chan error) { + errChan <- h.run(ctx, wg) + }(errs) select { case <-stop: diff --git a/pkg/termination/termination_suite_test.go b/pkg/termination/termination_suite_test.go index 4eb1ce33fd..6950a3cc99 100644 --- a/pkg/termination/termination_suite_test.go +++ b/pkg/termination/termination_suite_test.go @@ -81,8 +81,8 @@ var _ = AfterSuite(func() { func StartTestHandler(th Handler) (chan struct{}, chan error) { stop := make(chan struct{}) errs := make(chan error) - go func() { - errs <- th.Run(stop) - }() + go func(stopChan chan struct{}) { + errs <- th.Run(stopChan) + }(stop) return stop, errs }