diff --git a/multipool.go b/multipool.go index ad5db10..3f78ce2 100644 --- a/multipool.go +++ b/multipool.go @@ -201,16 +201,9 @@ func (mp *MultiPool) ReleaseTimeout(timeout time.Duration) error { _ = wg.Wait() - var ( - i int - errStr strings.Builder - ) - for err := range errCh { - i++ - if i == len(mp.pools) { - break - } - if err != nil { + var errStr strings.Builder + for i := 0; i < len(mp.pools); i++ { + if err := <-errCh; err != nil { errStr.WriteString(err.Error()) errStr.WriteString(" | ") } diff --git a/multipool_func.go b/multipool_func.go index 257b16e..868c0de 100644 --- a/multipool_func.go +++ b/multipool_func.go @@ -191,16 +191,9 @@ func (mp *MultiPoolWithFunc) ReleaseTimeout(timeout time.Duration) error { _ = wg.Wait() - var ( - i int - errStr strings.Builder - ) - for err := range errCh { - i++ - if i == len(mp.pools) { - break - } - if err != nil { + var errStr strings.Builder + for i := 0; i < len(mp.pools); i++ { + if err := <-errCh; err != nil { errStr.WriteString(err.Error()) errStr.WriteString(" | ") }