Codebase list golang-github-vbauerster-mpb / 815a52d
example_test update Vladimir Bauer 9 years ago
2 changed file(s) with 2 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
4747 bar := p.AddBar(100).PrependName("Single Bar:", 0, 0).AppendPercentage(5, 0)
4848
4949 for i := 0; i < 100; i++ {
50 time.Sleep(time.Duration(rand.Intn(100)) * time.Millisecond)
5051 bar.Incr(1) // increment progress bar
51 time.Sleep(time.Duration(rand.Intn(100)) * time.Millisecond)
5252 }
5353
5454 // Don't forget to stop mpb's rendering goroutine
5555 p.Stop()
56
57 // You cannot add bars after p.Stop() has been called
58 // p.AddBar(100) // will panic
5956 ```
6057
6158 Running [this](example/singleBar/main.go), will produce:
2828 AppendPercentage(5, 0)
2929
3030 for i := 0; i < 100; i++ {
31 time.Sleep(time.Duration(rand.Intn(100)) * time.Millisecond)
3132 bar.Incr(1) // increment progress bar
32 time.Sleep(time.Duration(rand.Intn(100)) * time.Millisecond)
3333 }
3434
3535 // Don't forget to stop mpb's rendering goroutine
3636 p.Stop()
37
38 // You cannot add bars after p.Stop() has been called
39 // p.AddBar(100) // will panic
4037 }
4138
4239 func ExampleBar_InProgress() {