update io examples
Vladimir Bauer
9 years ago
| 9 | 9 |
"sync"
|
| 10 | 10 |
|
| 11 | 11 |
"github.com/vbauerster/mpb"
|
|
12 |
"github.com/vbauerster/mpb/decor"
|
| 12 | 13 |
)
|
| 13 | 14 |
|
| 14 | 15 |
func main() {
|
|
| 18 | 19 |
url2 := "https://homebrew.bintray.com/bottles/libtiff-4.0.7.sierra.bottle.tar.gz"
|
| 19 | 20 |
|
| 20 | 21 |
var wg sync.WaitGroup
|
| 21 | |
p := mpb.New().SetWidth(60)
|
|
22 |
p := mpb.New(mpb.WithWidth(64))
|
| 22 | 23 |
|
| 23 | 24 |
for i, url := range [...]string{url1, url2} {
|
| 24 | 25 |
wg.Add(1)
|
|
| 58 | 59 |
}
|
| 59 | 60 |
|
| 60 | 61 |
// 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 |
)
|
| 65 | 69 |
|
| 66 | 70 |
// create proxy reader
|
| 67 | 71 |
reader := bar.ProxyReader(resp.Body)
|
| 7 | 7 |
"path/filepath"
|
| 8 | 8 |
|
| 9 | 9 |
"github.com/vbauerster/mpb"
|
|
10 |
"github.com/vbauerster/mpb/decor"
|
| 10 | 11 |
)
|
| 11 | 12 |
|
| 12 | 13 |
func main() {
|
|
| 34 | 35 |
}
|
| 35 | 36 |
defer dest.Close()
|
| 36 | 37 |
|
| 37 | |
p := mpb.New().SetWidth(64)
|
|
38 |
p := mpb.New(mpb.WithWidth(64))
|
| 38 | 39 |
|
| 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 |
))
|
| 42 | 44 |
|
| 43 | 45 |
// create proxy reader
|
| 44 | 46 |
reader := bar.ProxyReader(resp.Body)
|