examples refactoring
Vladimir Bauer
6 years ago
| 1 | 1 |
|
| 2 | 2 |
go 1.13
|
| 3 | 3 |
|
| 4 | |
require github.com/vbauerster/mpb/v4 v4.11.2
|
|
4 |
require github.com/vbauerster/mpb/v4 v4.11.3-0.20200204150524-c0b52b31e85a
|
| 23 | 23 |
name := fmt.Sprintf("Bar#%d:", i)
|
| 24 | 24 |
bar := p.AddBar(int64(total),
|
| 25 | 25 |
// set BarWidth 40 for bar 1 and 2
|
| 26 | |
mpb.BarOptOnCond(mpb.BarWidth(40), func() bool { return i > 0 }),
|
|
26 |
mpb.BarOptOn(mpb.BarWidth(40), func() bool { return i > 0 }),
|
| 27 | 27 |
mpb.PrependDecorators(
|
| 28 | 28 |
// simple name decorator
|
| 29 | 29 |
decor.Name(name),
|
| 1 | 1 |
|
| 2 | 2 |
go 1.13
|
| 3 | 3 |
|
| 4 | |
require github.com/vbauerster/mpb/v4 v4.11.2
|
|
4 |
require github.com/vbauerster/mpb/v4 v4.11.3-0.20200204150524-c0b52b31e85a
|
| 22 | 22 |
// pass &wg (optional), so p will wait for it eventually
|
| 23 | 23 |
p := mpb.New(
|
| 24 | 24 |
mpb.WithWaitGroup(&wg),
|
| 25 | |
mpb.ContainerOptOnCond(
|
|
25 |
mpb.ContainerOptOn(
|
| 26 | 26 |
// setting to nil will:
|
| 27 | 27 |
// set output to ioutil.Discard and disable internal refresh rate
|
| 28 | 28 |
// cycling, in order to not consume much CPU, hovewer a single refresh
|
| 1 | 1 |
|
| 2 | 2 |
go 1.13
|
| 3 | 3 |
|
| 4 | |
require github.com/vbauerster/mpb/v4 v4.11.2
|
|
4 |
require github.com/vbauerster/mpb/v4 v4.11.3-0.20200204150524-c0b52b31e85a
|
| 19 | 19 |
for i := 0; i < numBars; i++ {
|
| 20 | 20 |
name := fmt.Sprintf("Bar#%d:", i)
|
| 21 | 21 |
b := p.AddBar(int64(total), mpb.BarID(i),
|
| 22 | |
mpb.BarOptOnCond(mpb.BarRemoveOnComplete(), func() bool { return i == 0 }),
|
|
22 |
mpb.BarOptOn(mpb.BarRemoveOnComplete(), func() bool { return i == 0 }),
|
| 23 | 23 |
mpb.PrependDecorators(
|
| 24 | 24 |
decor.Name(name),
|
| 25 | 25 |
decor.EwmaETA(decor.ET_STYLE_GO, 60, decor.WCSyncSpace),
|
| 1 | 1 |
|
| 2 | 2 |
go 1.13
|
| 3 | 3 |
|
| 4 | |
require github.com/vbauerster/mpb/v4 v4.11.2
|
|
4 |
require github.com/vbauerster/mpb/v4 v4.11.3-0.20200204150524-c0b52b31e85a
|
| 20 | 20 |
name := fmt.Sprintf("Bar#%d:", i)
|
| 21 | 21 |
bar := p.AddBar(int64(total),
|
| 22 | 22 |
// reverse Bar#1
|
| 23 | |
mpb.BarOptOnCond(mpb.BarReverse(), func() bool { return i == 1 }),
|
|
23 |
mpb.BarOptOn(mpb.BarReverse(), func() bool { return i == 1 }),
|
| 24 | 24 |
mpb.PrependDecorators(
|
| 25 | 25 |
// simple name decorator
|
| 26 | 26 |
decor.Name(name),
|