refactor examples
Vladimir Bauer
7 years ago
| 38 | 38 |
|
| 39 | 39 |
p := mpb.New(
|
| 40 | 40 |
mpb.WithWidth(60),
|
| 41 | |
mpb.WithFormat("[=>-|"),
|
| 42 | 41 |
mpb.WithRefreshRate(180*time.Millisecond),
|
| 43 | 42 |
)
|
| 44 | 43 |
|
| 45 | |
bar := p.AddBar(size,
|
|
44 |
bar := p.AddBar(size, mpb.BarStyle("[=>-|"),
|
| 46 | 45 |
mpb.PrependDecorators(
|
| 47 | 46 |
decor.CountersKibiByte("% 6.1f / % 6.1f"),
|
| 48 | 47 |
),
|
| 11 | 11 |
p := mpb.New(
|
| 12 | 12 |
// override default (80) width
|
| 13 | 13 |
mpb.WithWidth(64),
|
| 14 | |
// override default "[=>-]" format
|
| 15 | |
mpb.WithFormat("╢▌▌░╟"),
|
| 16 | 14 |
// override default 120ms refresh rate
|
| 17 | 15 |
mpb.WithRefreshRate(180*time.Millisecond),
|
| 18 | 16 |
)
|
|
| 21 | 19 |
name := "Single Bar:"
|
| 22 | 20 |
// adding a single bar
|
| 23 | 21 |
bar := p.AddBar(int64(total),
|
|
22 |
// override default "[=>-]" style
|
|
23 |
mpb.BarStyle("╢▌▌░╟"),
|
| 24 | 24 |
mpb.PrependDecorators(
|
| 25 | 25 |
// display our name with one space on the right
|
| 26 | 26 |
decor.Name(name, decor.WC{W: len(name) + 1, C: decor.DidentRight}),
|
| 19 | 19 |
|
| 20 | 20 |
func main() {
|
| 21 | 21 |
var wg sync.WaitGroup
|
| 22 | |
p := mpb.New(mpb.WithWaitGroup(&wg))
|
|
22 |
p := mpb.New(
|
|
23 |
mpb.WithWaitGroup(&wg),
|
|
24 |
mpb.WithRefreshRate(50*time.Millisecond),
|
|
25 |
)
|
| 23 | 26 |
wg.Add(totalBars)
|
| 24 | 27 |
|
| 25 | 28 |
for i := 0; i < totalBars; i++ {
|