diff --git a/example/hang/main.go b/example/hang/main.go index f281397..8dffb97 100644 --- a/example/hang/main.go +++ b/example/hang/main.go @@ -19,7 +19,7 @@ return fmt.Sprintf("%-7s", str) } - p := mpb.New() + p := mpb.New(nil) bar := p.AddBar(totalItem).PrependFunc(decor).AppendETA(-6) blockSize := rand.Intn(maxBlockSize) + 1 diff --git a/example/io/multiple/main.go b/example/io/multiple/main.go index 1a07461..8f7f073 100644 --- a/example/io/multiple/main.go +++ b/example/io/multiple/main.go @@ -19,7 +19,7 @@ url2 := "https://homebrew.bintray.com/bottles/libtiff-4.0.7.sierra.bottle.tar.gz" var wg sync.WaitGroup - p := mpb.New().SetWidth(60) + p := mpb.New(nil).SetWidth(60) for i, url := range [...]string{url1, url2} { wg.Add(1) @@ -59,7 +59,7 @@ } // create bar with appropriate decorators - bar := p.AddBar(int(size)). + bar := p.AddBar(size). PrependName(name, len(name)). PrependCounters(mpb.UnitBytes, 20). AppendETA(-6) diff --git a/example/io/single/main.go b/example/io/single/main.go index 8508cae..fca49ec 100644 --- a/example/io/single/main.go +++ b/example/io/single/main.go @@ -35,9 +35,9 @@ } defer dest.Close() - p := mpb.New().SetWidth(64) + p := mpb.New(nil).SetWidth(64) - bar := p.AddBar(int(size)).PrependCounters(mpb.UnitBytes, 20).AppendETA(-6) + bar := p.AddBar(size).PrependCounters(mpb.UnitBytes, 20).AppendETA(-6) // create proxy reader reader := bar.ProxyReader(resp.Body) diff --git a/example/prependETA/main.go b/example/prependETA/main.go index a6a2625..f8dd01a 100644 --- a/example/prependETA/main.go +++ b/example/prependETA/main.go @@ -16,8 +16,8 @@ func main() { var wg sync.WaitGroup - p := mpb.New().SetWidth(64) - // p := mpb.New().RefreshRate(80 * time.Millisecond).SetWidth(64) + p := mpb.New(nil).SetWidth(64) + // p := mpb.New(nil).RefreshRate(80 * time.Millisecond).SetWidth(64) name1 := "Bar#1: " bar1 := p.AddBar(50). diff --git a/example/prependElapsed/main.go b/example/prependElapsed/main.go index 291cec7..bc7ee9a 100644 --- a/example/prependElapsed/main.go +++ b/example/prependElapsed/main.go @@ -16,8 +16,8 @@ func main() { var wg sync.WaitGroup - p := mpb.New().SetWidth(64) - // p := mpb.New().RefreshRate(80 * time.Millisecond).SetWidth(64) + p := mpb.New(nil).SetWidth(64) + // p := mpb.New(nil).RefreshRate(80 * time.Millisecond).SetWidth(64) name1 := "Bar#1: " bar1 := p.AddBar(50). diff --git a/example/remove/main.go b/example/remove/main.go index a9c372f..d47b750 100644 --- a/example/remove/main.go +++ b/example/remove/main.go @@ -16,8 +16,8 @@ func main() { var wg sync.WaitGroup - p := mpb.New().SetWidth(64) - // p := mpb.New().RefreshRate(100 * time.Millisecond).SetWidth(64) + p := mpb.New(nil).SetWidth(64) + // p := mpb.New(nil).RefreshRate(100 * time.Millisecond).SetWidth(64) name1 := "Bar#1: " bar1 := p.AddBar(50). diff --git a/example/simple/main.go b/example/simple/main.go index ca513fb..0c01e84 100644 --- a/example/simple/main.go +++ b/example/simple/main.go @@ -11,7 +11,7 @@ func main() { var wg sync.WaitGroup - p := mpb.New() // Star mpb's rendering goroutine + p := mpb.New(nil) // Star mpb's rendering goroutine for i := 0; i < 3; i++ { wg.Add(1) // add wg delta name := fmt.Sprintf("Bar#%d:", i) diff --git a/example/singleBar/main.go b/example/singleBar/main.go index 7e230a2..d23a8f3 100644 --- a/example/singleBar/main.go +++ b/example/singleBar/main.go @@ -11,7 +11,7 @@ func main() { name := "Single bar:" - p := mpb.New() + p := mpb.New(nil) bar := p.AddBar(100).PrependName(name, 0).AppendPercentage() for i := 0; i < 100; i++ { diff --git a/example/sort/main.go b/example/sort/main.go index 6e53521..213e41f 100644 --- a/example/sort/main.go +++ b/example/sort/main.go @@ -16,7 +16,7 @@ func main() { var wg sync.WaitGroup - p := mpb.New().SetWidth(60).WithSort(mpb.SortTop) + p := mpb.New(nil).SetWidth(60).WithSort(mpb.SortTop) name1 := "Bar#1: " bar1 := p.AddBar(100). diff --git a/format.go b/format.go index 8da03fa..de77992 100644 --- a/format.go +++ b/format.go @@ -20,12 +20,12 @@ UnitBytes ) -func Format(i int) *formatter { +func Format(i int64) *formatter { return &formatter{n: i} } type formatter struct { - n int + n int64 unit Units width int } @@ -49,7 +49,7 @@ } } -func formatBytes(i int) (result string) { +func formatBytes(i int64) (result string) { switch { case i > bytesInTiB: result = fmt.Sprintf("%.1fTiB", float64(i)/bytesInTiB)