example_test update
Vladimir Bauer
9 years ago
| 47 | 47 |
bar := p.AddBar(100).PrependName("Single Bar:", 0, 0).AppendPercentage(5, 0)
|
| 48 | 48 |
|
| 49 | 49 |
for i := 0; i < 100; i++ {
|
|
50 |
time.Sleep(time.Duration(rand.Intn(100)) * time.Millisecond)
|
| 50 | 51 |
bar.Incr(1) // increment progress bar
|
| 51 | |
time.Sleep(time.Duration(rand.Intn(100)) * time.Millisecond)
|
| 52 | 52 |
}
|
| 53 | 53 |
|
| 54 | 54 |
// Don't forget to stop mpb's rendering goroutine
|
| 55 | 55 |
p.Stop()
|
| 56 | |
|
| 57 | |
// You cannot add bars after p.Stop() has been called
|
| 58 | |
// p.AddBar(100) // will panic
|
| 59 | 56 |
```
|
| 60 | 57 |
|
| 61 | 58 |
Running [this](example/singleBar/main.go), will produce:
|
| 28 | 28 |
AppendPercentage(5, 0)
|
| 29 | 29 |
|
| 30 | 30 |
for i := 0; i < 100; i++ {
|
|
31 |
time.Sleep(time.Duration(rand.Intn(100)) * time.Millisecond)
|
| 31 | 32 |
bar.Incr(1) // increment progress bar
|
| 32 | |
time.Sleep(time.Duration(rand.Intn(100)) * time.Millisecond)
|
| 33 | 33 |
}
|
| 34 | 34 |
|
| 35 | 35 |
// Don't forget to stop mpb's rendering goroutine
|
| 36 | 36 |
p.Stop()
|
| 37 | |
|
| 38 | |
// You cannot add bars after p.Stop() has been called
|
| 39 | |
// p.AddBar(100) // will panic
|
| 40 | 37 |
}
|
| 41 | 38 |
|
| 42 | 39 |
func ExampleBar_InProgress() {
|