From f5295e5b8172fdac94132fe7c02c528db328385a Mon Sep 17 00:00:00 2001 From: Naitik Shah Date: Sun, 6 Oct 2013 12:19:25 -0700 Subject: [PATCH] use defer for wg.Done to ensure its called --- grace.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grace.go b/grace.go index d78a27e..81e5875 100644 --- a/grace.go +++ b/grace.go @@ -148,11 +148,11 @@ func Wait(listeners []Listener) (err error) { wg.Add(len(listeners)) for _, l := range listeners { go func(l Listener) { + defer wg.Done() cErr := l.Close() if cErr != nil { err = cErr } - wg.Done() }(l) } wg.Wait()