diff --git a/bar_test.go b/bar_test.go index 70cb3b7..22806df 100644 --- a/bar_test.go +++ b/bar_test.go @@ -38,12 +38,12 @@ wantID := 11 bar := p.AddBar(int64(total), BarID(wantID)) - go func(total int) { + go func() { for i := 0; i < total; i++ { time.Sleep(50 * time.Millisecond) bar.Increment() } - }(total) + }() gotID := bar.ID() if gotID != wantID { diff --git a/decorators_test.go b/decorators_test.go index ca58c73..092b575 100644 --- a/decorators_test.go +++ b/decorators_test.go @@ -4,7 +4,7 @@ "sync" "testing" - . "github.com/vbauerster/mpb/v5" + "github.com/vbauerster/mpb/v5" "github.com/vbauerster/mpb/v5/decor" ) @@ -182,18 +182,20 @@ t.Fail() } - numBars := len(testCases[0]) - var wg sync.WaitGroup for _, columnCase := range testCases { + mpb.SyncWidth(toSyncMatrix(columnCase)) + numBars := len(columnCase) + gott := make([]chan string, numBars) + wg := new(sync.WaitGroup) wg.Add(numBars) - SyncWidth(toSyncMatrix(columnCase)) - gott := make([]chan string, numBars) - for i := 0; i < numBars; i++ { - gott[i] = make(chan string, 1) - go func(s step, ch chan string) { + for i, step := range columnCase { + step := step + ch := make(chan string, 1) + go func() { defer wg.Done() - ch <- s.decorator.Decor(s.stat) - }(columnCase[i], gott[i]) + ch <- step.decorator.Decor(step.stat) + }() + gott[i] = ch } wg.Wait()