Codebase list golang-github-vbauerster-mpb / df92ffe
update io examples Vladimir Bauer 9 years ago
2 changed file(s) with 15 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
99 "sync"
1010
1111 "github.com/vbauerster/mpb"
12 "github.com/vbauerster/mpb/decor"
1213 )
1314
1415 func main() {
1819 url2 := "https://homebrew.bintray.com/bottles/libtiff-4.0.7.sierra.bottle.tar.gz"
1920
2021 var wg sync.WaitGroup
21 p := mpb.New().SetWidth(60)
22 p := mpb.New(mpb.WithWidth(64))
2223
2324 for i, url := range [...]string{url1, url2} {
2425 wg.Add(1)
5859 }
5960
6061 // create bar with appropriate decorators
61 bar := p.AddBar(size).
62 PrependName(name, 0, 0).
63 PrependCounters("%3s / %3s", mpb.UnitBytes, 18, mpb.DwidthSync|mpb.DextraSpace).
64 AppendETA(5, mpb.DwidthSync)
62 bar := p.AddBar(size,
63 mpb.PrependDecorators(
64 decor.Name(name, 0, 0),
65 decor.Counters("%3s / %3s", decor.Unit_KiB, 18, 0),
66 ),
67 mpb.AppendDecorators(decor.ETA(5, decor.DwidthSync)),
68 )
6569
6670 // create proxy reader
6771 reader := bar.ProxyReader(resp.Body)
77 "path/filepath"
88
99 "github.com/vbauerster/mpb"
10 "github.com/vbauerster/mpb/decor"
1011 )
1112
1213 func main() {
3435 }
3536 defer dest.Close()
3637
37 p := mpb.New().SetWidth(64)
38 p := mpb.New(mpb.WithWidth(64))
3839
39 bar := p.AddBar(size).
40 PrependCounters("%3s / %3s", mpb.UnitBytes, 18, 0).
41 AppendETA(3, 0)
40 bar := p.AddBar(size,
41 mpb.PrependDecorators(
42 decor.Counters("%3s / %3s", decor.Unit_KiB, 18, 0),
43 ))
4244
4345 // create proxy reader
4446 reader := bar.ProxyReader(resp.Body)