Codebase list golang-github-vbauerster-mpb / edd767b
some refactoring Vladimir Bauer 5 years ago
2 changed file(s) with 14 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
3737 wantID := 11
3838 bar := p.AddBar(int64(total), BarID(wantID))
3939
40 go func(total int) {
40 go func() {
4141 for i := 0; i < total; i++ {
4242 time.Sleep(50 * time.Millisecond)
4343 bar.Increment()
4444 }
45 }(total)
45 }()
4646
4747 gotID := bar.ID()
4848 if gotID != wantID {
33 "sync"
44 "testing"
55
6 . "github.com/vbauerster/mpb/v5"
6 "github.com/vbauerster/mpb/v5"
77 "github.com/vbauerster/mpb/v5/decor"
88 )
99
181181 t.Fail()
182182 }
183183
184 numBars := len(testCases[0])
185 var wg sync.WaitGroup
186184 for _, columnCase := range testCases {
185 mpb.SyncWidth(toSyncMatrix(columnCase))
186 numBars := len(columnCase)
187 gott := make([]chan string, numBars)
188 wg := new(sync.WaitGroup)
187189 wg.Add(numBars)
188 SyncWidth(toSyncMatrix(columnCase))
189 gott := make([]chan string, numBars)
190 for i := 0; i < numBars; i++ {
191 gott[i] = make(chan string, 1)
192 go func(s step, ch chan string) {
190 for i, step := range columnCase {
191 step := step
192 ch := make(chan string, 1)
193 go func() {
193194 defer wg.Done()
194 ch <- s.decorator.Decor(s.stat)
195 }(columnCase[i], gott[i])
195 ch <- step.decorator.Decor(step.stat)
196 }()
197 gott[i] = ch
196198 }
197199 wg.Wait()
198200