use defer for wg.Done to ensure its called
This commit is contained in:
parent
ae3f6c71a7
commit
f5295e5b81
2
grace.go
2
grace.go
@ -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()
|
||||||
|
Loading…
Reference in New Issue
Block a user