use defer for wg.Done to ensure its called

This commit is contained in:
Naitik Shah 2013-10-06 12:19:25 -07:00
parent ae3f6c71a7
commit f5295e5b81

View File

@ -148,11 +148,11 @@ func Wait(listeners []Listener) (err error) {
wg.Add(len(listeners)) wg.Add(len(listeners))
for _, l := range listeners { for _, l := range listeners {
go func(l Listener) { go func(l Listener) {
defer wg.Done()
cErr := l.Close() cErr := l.Close()
if cErr != nil { if cErr != nil {
err = cErr err = cErr
} }
wg.Done()
}(l) }(l)
} }
wg.Wait() wg.Wait()