examples update
Vladimir Bauer
9 years ago
| 18 | 18 |
return fmt.Sprintf("%-7s", str)
|
| 19 | 19 |
}
|
| 20 | 20 |
|
| 21 | |
p := mpb.New()
|
|
21 |
p := mpb.New(nil)
|
| 22 | 22 |
bar := p.AddBar(totalItem).PrependFunc(decor).AppendETA(-6)
|
| 23 | 23 |
|
| 24 | 24 |
blockSize := rand.Intn(maxBlockSize) + 1
|
| 18 | 18 |
url2 := "https://homebrew.bintray.com/bottles/libtiff-4.0.7.sierra.bottle.tar.gz"
|
| 19 | 19 |
|
| 20 | 20 |
var wg sync.WaitGroup
|
| 21 | |
p := mpb.New().SetWidth(60)
|
|
21 |
p := mpb.New(nil).SetWidth(60)
|
| 22 | 22 |
|
| 23 | 23 |
for i, url := range [...]string{url1, url2} {
|
| 24 | 24 |
wg.Add(1)
|
|
| 58 | 58 |
}
|
| 59 | 59 |
|
| 60 | 60 |
// create bar with appropriate decorators
|
| 61 | |
bar := p.AddBar(int(size)).
|
|
61 |
bar := p.AddBar(size).
|
| 62 | 62 |
PrependName(name, len(name)).
|
| 63 | 63 |
PrependCounters(mpb.UnitBytes, 20).
|
| 64 | 64 |
AppendETA(-6)
|
| 34 | 34 |
}
|
| 35 | 35 |
defer dest.Close()
|
| 36 | 36 |
|
| 37 | |
p := mpb.New().SetWidth(64)
|
|
37 |
p := mpb.New(nil).SetWidth(64)
|
| 38 | 38 |
|
| 39 | |
bar := p.AddBar(int(size)).PrependCounters(mpb.UnitBytes, 20).AppendETA(-6)
|
|
39 |
bar := p.AddBar(size).PrependCounters(mpb.UnitBytes, 20).AppendETA(-6)
|
| 40 | 40 |
|
| 41 | 41 |
// create proxy reader
|
| 42 | 42 |
reader := bar.ProxyReader(resp.Body)
|
| 15 | 15 |
func main() {
|
| 16 | 16 |
|
| 17 | 17 |
var wg sync.WaitGroup
|
| 18 | |
p := mpb.New().SetWidth(64)
|
| 19 | |
// p := mpb.New().RefreshRate(80 * time.Millisecond).SetWidth(64)
|
|
18 |
p := mpb.New(nil).SetWidth(64)
|
|
19 |
// p := mpb.New(nil).RefreshRate(80 * time.Millisecond).SetWidth(64)
|
| 20 | 20 |
|
| 21 | 21 |
name1 := "Bar#1: "
|
| 22 | 22 |
bar1 := p.AddBar(50).
|
| 15 | 15 |
func main() {
|
| 16 | 16 |
|
| 17 | 17 |
var wg sync.WaitGroup
|
| 18 | |
p := mpb.New().SetWidth(64)
|
| 19 | |
// p := mpb.New().RefreshRate(80 * time.Millisecond).SetWidth(64)
|
|
18 |
p := mpb.New(nil).SetWidth(64)
|
|
19 |
// p := mpb.New(nil).RefreshRate(80 * time.Millisecond).SetWidth(64)
|
| 20 | 20 |
|
| 21 | 21 |
name1 := "Bar#1: "
|
| 22 | 22 |
bar1 := p.AddBar(50).
|
| 15 | 15 |
func main() {
|
| 16 | 16 |
|
| 17 | 17 |
var wg sync.WaitGroup
|
| 18 | |
p := mpb.New().SetWidth(64)
|
| 19 | |
// p := mpb.New().RefreshRate(100 * time.Millisecond).SetWidth(64)
|
|
18 |
p := mpb.New(nil).SetWidth(64)
|
|
19 |
// p := mpb.New(nil).RefreshRate(100 * time.Millisecond).SetWidth(64)
|
| 20 | 20 |
|
| 21 | 21 |
name1 := "Bar#1: "
|
| 22 | 22 |
bar1 := p.AddBar(50).
|
| 10 | 10 |
|
| 11 | 11 |
func main() {
|
| 12 | 12 |
var wg sync.WaitGroup
|
| 13 | |
p := mpb.New() // Star mpb's rendering goroutine
|
|
13 |
p := mpb.New(nil) // Star mpb's rendering goroutine
|
| 14 | 14 |
for i := 0; i < 3; i++ {
|
| 15 | 15 |
wg.Add(1) // add wg delta
|
| 16 | 16 |
name := fmt.Sprintf("Bar#%d:", i)
|
| 10 | 10 |
func main() {
|
| 11 | 11 |
|
| 12 | 12 |
name := "Single bar:"
|
| 13 | |
p := mpb.New()
|
|
13 |
p := mpb.New(nil)
|
| 14 | 14 |
bar := p.AddBar(100).PrependName(name, 0).AppendPercentage()
|
| 15 | 15 |
|
| 16 | 16 |
for i := 0; i < 100; i++ {
|
| 15 | 15 |
func main() {
|
| 16 | 16 |
|
| 17 | 17 |
var wg sync.WaitGroup
|
| 18 | |
p := mpb.New().SetWidth(60).WithSort(mpb.SortTop)
|
|
18 |
p := mpb.New(nil).SetWidth(60).WithSort(mpb.SortTop)
|
| 19 | 19 |
|
| 20 | 20 |
name1 := "Bar#1: "
|
| 21 | 21 |
bar1 := p.AddBar(100).
|
| 19 | 19 |
UnitBytes
|
| 20 | 20 |
)
|
| 21 | 21 |
|
| 22 | |
func Format(i int) *formatter {
|
|
22 |
func Format(i int64) *formatter {
|
| 23 | 23 |
return &formatter{n: i}
|
| 24 | 24 |
}
|
| 25 | 25 |
|
| 26 | 26 |
type formatter struct {
|
| 27 | |
n int
|
|
27 |
n int64
|
| 28 | 28 |
unit Units
|
| 29 | 29 |
width int
|
| 30 | 30 |
}
|
|
| 48 | 48 |
}
|
| 49 | 49 |
}
|
| 50 | 50 |
|
| 51 | |
func formatBytes(i int) (result string) {
|
|
51 |
func formatBytes(i int64) (result string) {
|
| 52 | 52 |
switch {
|
| 53 | 53 |
case i > bytesInTiB:
|
| 54 | 54 |
result = fmt.Sprintf("%.1fTiB", float64(i)/bytesInTiB)
|