diff --git a/README.md b/README.md index e42de07..ff61341 100644 --- a/README.md +++ b/README.md @@ -39,8 +39,8 @@ bar := p.AddBar(100).PrependName("Single Bar:", 0).AppendPercentage() for i := 0; i < 100; i++ { + bar.Incr(1) // increment progress bar time.Sleep(time.Duration(rand.Intn(100)) * time.Millisecond) - bar.Incr(1) } // Don't forget to stop mpb's rendering goroutine @@ -70,8 +70,8 @@ // if you still need p.AddBar() here and maintain ordering, use // (*mpb.Progress).BeforeRenderFunc(f mpb.BeforeRender) for i := 0; i < 100; i++ { + bar.Incr(1) time.Sleep(time.Duration(rand.Intn(100)) * time.Millisecond) - bar.Incr(1) } }() } diff --git a/example/hang/main.go b/example/hang/main.go index 8dffb97..014bc30 100644 --- a/example/hang/main.go +++ b/example/hang/main.go @@ -16,7 +16,7 @@ func main() { decor := func(s *mpb.Statistics) string { str := fmt.Sprintf("%d/%d", s.Current, s.Total) - return fmt.Sprintf("%-7s", str) + return fmt.Sprintf("%8s", str) } p := mpb.New(nil) @@ -27,9 +27,9 @@ // use bar.InProgress() bool method // for i := 0; bar.InProgress(); i += blockSize { for i := 0; i < totalItem; i += blockSize { - time.Sleep(time.Duration(blockSize) * (50*time.Millisecond + time.Duration(rand.Intn(5*int(time.Millisecond))))) bar.Incr(blockSize) blockSize = rand.Intn(maxBlockSize) + 1 + time.Sleep(time.Duration(blockSize) * (50*time.Millisecond + time.Duration(rand.Intn(5*int(time.Millisecond))))) } p.Stop() diff --git a/example/simple/main.go b/example/simple/main.go index 2a7a267..6b564ad 100644 --- a/example/simple/main.go +++ b/example/simple/main.go @@ -22,8 +22,8 @@ // if you still need p.AddBar() here and maintain ordering, use // (*mpb.Progress).BeforeRenderFunc(f mpb.BeforeRender) for i := 0; i < 100; i++ { + bar.Incr(1) time.Sleep(time.Duration(rand.Intn(100)) * time.Millisecond) - bar.Incr(1) } }() } diff --git a/example/singleBar/main.go b/example/singleBar/main.go index 0d2878f..433e639 100644 --- a/example/singleBar/main.go +++ b/example/singleBar/main.go @@ -24,8 +24,8 @@ bar := p.AddBar(100).PrependName("Single Bar:", 0).AppendPercentage() for i := 0; i < 100; i++ { + bar.Incr(1) // increment progress bar time.Sleep(time.Duration(rand.Intn(100)) * time.Millisecond) - bar.Incr(1) } // Don't forget to stop mpb's rendering goroutine