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))
for _, l := range listeners {
go func(l Listener) {
defer wg.Done()
cErr := l.Close()
if cErr != nil {
err = cErr
}
wg.Done()
}(l)
}
wg.Wait()