singleBar example update
Vladimir Bauer
9 years ago
| 0 | 0 | package main |
| 1 | 1 | |
| 2 | 2 | import ( |
| 3 | "fmt" | |
| 3 | 4 | "math/rand" |
| 4 | 5 | "time" |
| 5 | 6 | |
| 10 | 11 | // Star mpb's rendering goroutine. |
| 11 | 12 | p := mpb.New() |
| 12 | 13 | // Set custom width for every bar, which mpb will render |
| 13 | // The default one in 70 | |
| 14 | p.SetWidth(80) | |
| 14 | // The default one in 80 | |
| 15 | p.SetWidth(100) | |
| 15 | 16 | // Set custom format for every bar, the default one is "[=>-]" |
| 16 | 17 | p.Format("╢▌▌░╟") |
| 17 | 18 | // Set custom refresh rate, the default one is 100 ms |
| 27 | 28 | |
| 28 | 29 | // Don't forget to stop mpb's rendering goroutine |
| 29 | 30 | p.Stop() |
| 30 | ||
| 31 | // You cannot add bars after p.Stop() has been called | |
| 32 | // p.AddBar(100) // will panic | |
| 31 | fmt.Println("Stop") | |
| 33 | 32 | } |