WithWidth 64
Vladimir Bauer
8 years ago
| 12 | 12 |
}
|
| 13 | 13 |
|
| 14 | 14 |
func main() {
|
| 15 | |
p := mpb.New()
|
|
15 |
p := mpb.New(mpb.WithWidth(64))
|
| 16 | 16 |
|
| 17 | 17 |
// initialize bar with dynamic total and initial total guess = 80
|
| 18 | 18 |
bar := p.AddBar(80,
|
|
| 24 | 24 |
decor.CountersNoUnit("%d / %d", 12, 0),
|
| 25 | 25 |
),
|
| 26 | 26 |
mpb.AppendDecorators(
|
| 27 | |
decor.Percentage(5, 0),
|
|
27 |
decor.Percentage(4, 0),
|
| 28 | 28 |
),
|
| 29 | 29 |
)
|
| 30 | 30 |
|
| 19 | 19 |
url2 := "https://homebrew.bintray.com/bottles/libtiff-4.0.7.sierra.bottle.tar.gz"
|
| 20 | 20 |
|
| 21 | 21 |
var wg sync.WaitGroup
|
| 22 | |
p := mpb.New(mpb.WithWaitGroup(&wg))
|
|
22 |
p := mpb.New(mpb.WithWidth(64), mpb.WithWaitGroup(&wg))
|
| 23 | 23 |
|
| 24 | 24 |
for i, url := range [...]string{url1, url2} {
|
| 25 | 25 |
wg.Add(1)
|
|
| 28 | 28 |
}
|
| 29 | 29 |
|
| 30 | 30 |
p.Wait()
|
| 31 | |
fmt.Println("done")
|
| 32 | 31 |
}
|
| 33 | 32 |
|
| 34 | 33 |
func download(wg *sync.WaitGroup, p *mpb.Progress, name, url string, n int) {
|
|
| 63 | 62 |
decor.StaticName(name, len(name)+1, decor.DidentRight),
|
| 64 | 63 |
decor.CountersKibiByte("%6.1f / %6.1f", 0, decor.DwidthSync),
|
| 65 | 64 |
),
|
| 66 | |
mpb.AppendDecorators(decor.ETA(3, 0)),
|
|
65 |
mpb.AppendDecorators(decor.ETA(0, decor.DwidthSync)),
|
| 67 | 66 |
)
|
| 68 | 67 |
|
| 69 | 68 |
// create proxy reader
|