Refactor: godoc examples
Vladimir Bauer
8 years ago
| 37 | 37 | ), |
| 38 | 38 | ) |
| 39 | 39 | |
| 40 | max := 200 * time.Millisecond | |
| 40 | 41 | for i := 0; i < total; i++ { |
| 41 | time.Sleep(time.Duration(rand.Intn(10)+1) * (200 * time.Millisecond) / 10) | |
| 42 | time.Sleep(time.Duration(rand.Intn(10)+1) * max / 10) | |
| 42 | 43 | bar.Increment() |
| 43 | 44 | } |
| 44 | 45 | |
| 47 | 48 | |
| 48 | 49 | func ExampleBar_Completed() { |
| 49 | 50 | p := mpb.New() |
| 50 | bar := p.AddBar(100, mpb.AppendDecorators(decor.Percentage(5, 0))) | |
| 51 | bar := p.AddBar(100) | |
| 51 | 52 | |
| 53 | max := 200 * time.Millisecond | |
| 52 | 54 | for !bar.Completed() { |
| 53 | time.Sleep(time.Duration(rand.Intn(10)+1) * (200 * time.Millisecond) / 10) | |
| 55 | time.Sleep(time.Duration(rand.Intn(10)+1) * max / 10) | |
| 54 | 56 | bar.Increment() |
| 55 | 57 | } |
| 58 | ||
| 59 | p.Stop() | |
| 56 | 60 | } |