diff --git a/_examples/barExtender/go.mod b/_examples/barExtender/go.mod index 8a1f894..c221fab 100644 --- a/_examples/barExtender/go.mod +++ b/_examples/barExtender/go.mod @@ -1,5 +1,7 @@ module github.com/vbauerster/mpb/_examples/barExtender -go 1.13 +go 1.14 -require github.com/vbauerster/mpb/v4 v4.12.0 +require github.com/vbauerster/mpb/v5 v5.0.0 + +replace github.com/vbauerster/mpb/v5 => /Users/vbauer/gohack/github.com/vbauerster/mpb/v5 diff --git a/_examples/barExtender/main.go b/_examples/barExtender/main.go index d397494..cf09f6e 100644 --- a/_examples/barExtender/main.go +++ b/_examples/barExtender/main.go @@ -7,8 +7,8 @@ "sync" "time" - "github.com/vbauerster/mpb/v4" - "github.com/vbauerster/mpb/v4/decor" + "github.com/vbauerster/mpb/v5" + "github.com/vbauerster/mpb/v5/decor" ) func main() { @@ -24,7 +24,7 @@ fmt.Fprintf(w, "Bar id: %d has been completed\n", s.ID) } } - bar := p.AddBar(int64(total), mpb.BarExtender(mpb.FillerFunc(efn)), + bar := p.AddBar(int64(total), mpb.BarExtender(mpb.BarFillerFunc(efn)), mpb.PrependDecorators( // simple name decorator decor.Name(name), @@ -45,10 +45,13 @@ rng := rand.New(rand.NewSource(time.Now().UnixNano())) max := 100 * time.Millisecond for i := 0; i < total; i++ { + // start variable is solely for EWMA calculation + // EWMA's unit of measure is an iteration's taken time start := time.Now() time.Sleep(time.Duration(rng.Intn(10)+1) * max / 10) - // since ewma decorator is used, we need to pass time.Since(start) - bar.Increment(time.Since(start)) + bar.Increment() + // since EWMA based decorator is used, DecoratorEwmaUpdate should be called + bar.DecoratorEwmaUpdate(time.Since(start)) } }() } diff --git a/_examples/cancel/go.mod b/_examples/cancel/go.mod index 31e0608..c0fa511 100644 --- a/_examples/cancel/go.mod +++ b/_examples/cancel/go.mod @@ -1,5 +1,5 @@ module github.com/vbauerster/mpb/_examples/cancel -go 1.13 +go 1.14 -require github.com/vbauerster/mpb/v4 v4.12.0 +require github.com/vbauerster/mpb/v5 v5.0.0 diff --git a/_examples/cancel/main.go b/_examples/cancel/main.go index 1c35038..52c1adb 100644 --- a/_examples/cancel/main.go +++ b/_examples/cancel/main.go @@ -7,8 +7,8 @@ "sync" "time" - "github.com/vbauerster/mpb/v4" - "github.com/vbauerster/mpb/v4/decor" + "github.com/vbauerster/mpb/v5" + "github.com/vbauerster/mpb/v5/decor" ) func main() { @@ -39,10 +39,13 @@ rng := rand.New(rand.NewSource(time.Now().UnixNano())) max := 100 * time.Millisecond for !bar.Completed() { + // start variable is solely for EWMA calculation + // EWMA's unit of measure is an iteration's taken time start := time.Now() time.Sleep(time.Duration(rng.Intn(10)+1) * max / 10) - // since ewma decorator is used, we need to pass time.Since(start) - bar.Increment(time.Since(start)) + bar.Increment() + // since EWMA based decorator is used, DecoratorEwmaUpdate should be called + bar.DecoratorEwmaUpdate(time.Since(start)) } }() } diff --git a/_examples/complex/go.mod b/_examples/complex/go.mod index f286f89..2fba6f6 100644 --- a/_examples/complex/go.mod +++ b/_examples/complex/go.mod @@ -1,5 +1,5 @@ module github.com/vbauerster/mpb/_examples/complex -go 1.13 +go 1.14 -require github.com/vbauerster/mpb/v4 v4.12.0 +require github.com/vbauerster/mpb/v5 v5.0.0 diff --git a/_examples/complex/main.go b/_examples/complex/main.go index 891bd74..72c2b01 100644 --- a/_examples/complex/main.go +++ b/_examples/complex/main.go @@ -6,8 +6,8 @@ "sync" "time" - "github.com/vbauerster/mpb/v4" - "github.com/vbauerster/mpb/v4/decor" + "github.com/vbauerster/mpb/v5" + "github.com/vbauerster/mpb/v5/decor" ) func init() { @@ -47,8 +47,8 @@ job := "\x1b[31;1;4minstalling\x1b[0m" // preparing delayed bars b := p.AddBar(rand.Int63n(101)+100, - mpb.BarParkTo(bars[i]), - mpb.BarClearOnComplete(), + mpb.BarQueueAfter(bars[i]), + mpb.BarFillerClearOnComplete(), mpb.PrependDecorators( decor.Name(task, decor.WC{W: len(task) + 1, C: decor.DidentRight}), decor.OnComplete(decor.Name(job, decor.WCSyncSpaceR), "done!"), @@ -67,13 +67,16 @@ p.Wait() } -func newTask(wg *sync.WaitGroup, b *mpb.Bar, incrBy int) { +func newTask(wg *sync.WaitGroup, bar *mpb.Bar, incrBy int) { defer wg.Done() max := 100 * time.Millisecond - for !b.Completed() { + for !bar.Completed() { + // start variable is solely for EWMA calculation + // EWMA's unit of measure is an iteration's taken time start := time.Now() time.Sleep(time.Duration(rand.Intn(10)+1) * max / 10) - // since ewma decorator is used, we need to pass time.Since(start) - b.IncrBy(incrBy, time.Since(start)) + bar.IncrBy(incrBy) + // we need to call DecoratorEwmaUpdate to fulfill ewma decorator's contract + bar.DecoratorEwmaUpdate(time.Since(start)) } } diff --git a/_examples/differentWidth/go.mod b/_examples/differentWidth/go.mod index c0b55f0..36343a0 100644 --- a/_examples/differentWidth/go.mod +++ b/_examples/differentWidth/go.mod @@ -1,5 +1,5 @@ module github.com/vbauerster/mpb/_examples/differentWidth -go 1.13 +go 1.14 -require github.com/vbauerster/mpb/v4 v4.12.0 +require github.com/vbauerster/mpb/v5 v5.0.0 diff --git a/_examples/differentWidth/main.go b/_examples/differentWidth/main.go index e8b8716..95ac902 100644 --- a/_examples/differentWidth/main.go +++ b/_examples/differentWidth/main.go @@ -6,8 +6,8 @@ "sync" "time" - "github.com/vbauerster/mpb/v4" - "github.com/vbauerster/mpb/v4/decor" + "github.com/vbauerster/mpb/v5" + "github.com/vbauerster/mpb/v5/decor" ) func main() { @@ -45,10 +45,13 @@ rng := rand.New(rand.NewSource(time.Now().UnixNano())) max := 100 * time.Millisecond for i := 0; i < total; i++ { + // start variable is solely for EWMA calculation + // EWMA's unit of measure is an iteration's taken time start := time.Now() time.Sleep(time.Duration(rng.Intn(10)+1) * max / 10) - // since ewma decorator is used, we need to pass time.Since(start) - bar.Increment(time.Since(start)) + bar.Increment() + // we need to call DecoratorEwmaUpdate to fulfill ewma decorator's contract + bar.DecoratorEwmaUpdate(time.Since(start)) } }() } diff --git a/_examples/dynTotal/go.mod b/_examples/dynTotal/go.mod index 7aef39f..dfc9978 100644 --- a/_examples/dynTotal/go.mod +++ b/_examples/dynTotal/go.mod @@ -1,5 +1,5 @@ module github.com/vbauerster/mpb/_examples/dynTotal -go 1.13 +go 1.14 -require github.com/vbauerster/mpb/v4 v4.12.0 +require github.com/vbauerster/mpb/v5 v5.0.0 diff --git a/_examples/dynTotal/main.go b/_examples/dynTotal/main.go index 62a6f64..55e8c0e 100644 --- a/_examples/dynTotal/main.go +++ b/_examples/dynTotal/main.go @@ -5,8 +5,8 @@ "math/rand" "time" - "github.com/vbauerster/mpb/v4" - "github.com/vbauerster/mpb/v4/decor" + "github.com/vbauerster/mpb/v5" + "github.com/vbauerster/mpb/v5/decor" ) func init() { diff --git a/_examples/io/go.mod b/_examples/io/go.mod index 1d9bda2..7c729a0 100644 --- a/_examples/io/go.mod +++ b/_examples/io/go.mod @@ -1,5 +1,5 @@ module github.com/vbauerster/mpb/_examples/io -go 1.13 +go 1.14 -require github.com/vbauerster/mpb/v4 v4.12.0 +require github.com/vbauerster/mpb/v5 v5.0.0 diff --git a/_examples/io/main.go b/_examples/io/main.go index e90d48e..00a6dcd 100644 --- a/_examples/io/main.go +++ b/_examples/io/main.go @@ -6,8 +6,8 @@ "io/ioutil" "time" - "github.com/vbauerster/mpb/v4" - "github.com/vbauerster/mpb/v4/decor" + "github.com/vbauerster/mpb/v5" + "github.com/vbauerster/mpb/v5/decor" ) func main() { diff --git a/_examples/merge/go.mod b/_examples/merge/go.mod index 92b068b..108df1b 100644 --- a/_examples/merge/go.mod +++ b/_examples/merge/go.mod @@ -1,5 +1,5 @@ module github.com/vbauerster/mpb/_examples/merge -go 1.13 +go 1.14 -require github.com/vbauerster/mpb/v4 v4.12.0 +require github.com/vbauerster/mpb/v5 v5.0.0 diff --git a/_examples/merge/main.go b/_examples/merge/main.go index 509f1bc..f1d7e43 100644 --- a/_examples/merge/main.go +++ b/_examples/merge/main.go @@ -6,8 +6,8 @@ "sync" "time" - "github.com/vbauerster/mpb/v4" - "github.com/vbauerster/mpb/v4/decor" + "github.com/vbauerster/mpb/v5" + "github.com/vbauerster/mpb/v5/decor" ) func main() { @@ -47,10 +47,13 @@ rng := rand.New(rand.NewSource(time.Now().UnixNano())) max := 100 * time.Millisecond for i := 0; i < total; i++ { + // start variable is solely for EWMA calculation + // EWMA's unit of measure is an iteration's taken time start := time.Now() time.Sleep(time.Duration(rng.Intn(10)+1) * max / 10) - // since ewma decorator is used, we need to pass time.Since(start) - bar.Increment(time.Since(start)) + bar.Increment() + // we need to call DecoratorEwmaUpdate to fulfill ewma decorator's contract + bar.DecoratorEwmaUpdate(time.Since(start)) } }() } diff --git a/_examples/multiBars/go.mod b/_examples/multiBars/go.mod index 92cb0d6..ddcf303 100644 --- a/_examples/multiBars/go.mod +++ b/_examples/multiBars/go.mod @@ -1,5 +1,5 @@ module github.com/vbauerster/mpb/_examples/multiBars -go 1.13 +go 1.14 -require github.com/vbauerster/mpb/v4 v4.12.0 +require github.com/vbauerster/mpb/v5 v5.0.0 diff --git a/_examples/multiBars/main.go b/_examples/multiBars/main.go index b249979..3e7973b 100644 --- a/_examples/multiBars/main.go +++ b/_examples/multiBars/main.go @@ -6,8 +6,8 @@ "sync" "time" - "github.com/vbauerster/mpb/v4" - "github.com/vbauerster/mpb/v4/decor" + "github.com/vbauerster/mpb/v5" + "github.com/vbauerster/mpb/v5/decor" ) func main() { @@ -40,10 +40,13 @@ rng := rand.New(rand.NewSource(time.Now().UnixNano())) max := 100 * time.Millisecond for i := 0; i < total; i++ { + // start variable is solely for EWMA calculation + // EWMA's unit of measure is an iteration's taken time start := time.Now() time.Sleep(time.Duration(rng.Intn(10)+1) * max / 10) - // since ewma decorator is used, we need to pass time.Since(start) - bar.Increment(time.Since(start)) + bar.Increment() + // we need to call DecoratorEwmaUpdate to fulfill ewma decorator's contract + bar.DecoratorEwmaUpdate(time.Since(start)) } }() } diff --git a/_examples/panic/go.mod b/_examples/panic/go.mod index 61751b8..410d8c9 100644 --- a/_examples/panic/go.mod +++ b/_examples/panic/go.mod @@ -1,5 +1,5 @@ module github.com/vbauerster/mpb/_examples/panic -go 1.13 +go 1.14 -require github.com/vbauerster/mpb/v4 v4.12.0 +require github.com/vbauerster/mpb/v5 v5.0.0 diff --git a/_examples/panic/main.go b/_examples/panic/main.go index 39c014c..1a7cfc1 100644 --- a/_examples/panic/main.go +++ b/_examples/panic/main.go @@ -6,8 +6,8 @@ "sync" "time" - "github.com/vbauerster/mpb/v4" - "github.com/vbauerster/mpb/v4/decor" + "github.com/vbauerster/mpb/v5" + "github.com/vbauerster/mpb/v5/decor" ) func main() { diff --git a/_examples/poplog/go.mod b/_examples/poplog/go.mod index 660c667..09a18d1 100644 --- a/_examples/poplog/go.mod +++ b/_examples/poplog/go.mod @@ -1,5 +1,5 @@ module github.com/vbauerster/mpb/_examples/poplog -go 1.13 +go 1.14 -require github.com/vbauerster/mpb/v4 v4.12.0 +require github.com/vbauerster/mpb/v5 v5.0.0 diff --git a/_examples/poplog/main.go b/_examples/poplog/main.go index 925807b..811ad5c 100644 --- a/_examples/poplog/main.go +++ b/_examples/poplog/main.go @@ -7,8 +7,8 @@ "sync" "time" - "github.com/vbauerster/mpb/v4" - "github.com/vbauerster/mpb/v4/decor" + "github.com/vbauerster/mpb/v5" + "github.com/vbauerster/mpb/v5/decor" ) func main() { @@ -34,9 +34,13 @@ rng := rand.New(rand.NewSource(time.Now().UnixNano())) max := 100 * time.Millisecond for i := 0; i < total; i++ { + // start variable is solely for EWMA calculation + // EWMA's unit of measure is an iteration's taken time start := time.Now() time.Sleep(time.Duration(rng.Intn(10)+1) * max / 10) - bar.Increment(time.Since(start)) + bar.Increment() + // we need to call DecoratorEwmaUpdate to fulfill ewma decorator's contract + bar.DecoratorEwmaUpdate(time.Since(start)) } }() } @@ -58,9 +62,9 @@ p.Wait() } -func makeLogBar(msg string) mpb.Filler { +func makeLogBar(msg string) mpb.BarFiller { limit := "%%.%ds" - return mpb.FillerFunc(func(w io.Writer, width int, st *decor.Statistics) { + return mpb.BarFillerFunc(func(w io.Writer, width int, st *decor.Statistics) { fmt.Fprintf(w, fmt.Sprintf(limit, width), msg) }) } diff --git a/_examples/quietMode/go.mod b/_examples/quietMode/go.mod index 2dd7340..534bc8e 100644 --- a/_examples/quietMode/go.mod +++ b/_examples/quietMode/go.mod @@ -1,5 +1,5 @@ module github.com/vbauerster/mpb/_examples/quietMode -go 1.13 +go 1.14 -require github.com/vbauerster/mpb/v4 v4.12.0 +require github.com/vbauerster/mpb/v5 v5.0.0 diff --git a/_examples/quietMode/main.go b/_examples/quietMode/main.go index 5e5b0fb..1beab45 100644 --- a/_examples/quietMode/main.go +++ b/_examples/quietMode/main.go @@ -7,8 +7,8 @@ "sync" "time" - "github.com/vbauerster/mpb/v4" - "github.com/vbauerster/mpb/v4/decor" + "github.com/vbauerster/mpb/v5" + "github.com/vbauerster/mpb/v5/decor" ) var quietMode bool @@ -58,10 +58,13 @@ rng := rand.New(rand.NewSource(time.Now().UnixNano())) max := 100 * time.Millisecond for i := 0; i < total; i++ { + // start variable is solely for EWMA calculation + // EWMA's unit of measure is an iteration's taken time start := time.Now() time.Sleep(time.Duration(rng.Intn(10)+1) * max / 10) - // since ewma decorator is used, we need to pass time.Since(start) - bar.Increment(time.Since(start)) + bar.Increment() + // we need to call DecoratorEwmaUpdate to fulfill ewma decorator's contract + bar.DecoratorEwmaUpdate(time.Since(start)) } }() } diff --git a/_examples/remove/go.mod b/_examples/remove/go.mod index 4e29745..1c77c89 100644 --- a/_examples/remove/go.mod +++ b/_examples/remove/go.mod @@ -1,5 +1,5 @@ module github.com/vbauerster/mpb/_examples/remove -go 1.13 +go 1.14 -require github.com/vbauerster/mpb/v4 v4.12.0 +require github.com/vbauerster/mpb/v5 v5.0.0 diff --git a/_examples/remove/main.go b/_examples/remove/main.go index ec66b17..57b5a1a 100644 --- a/_examples/remove/main.go +++ b/_examples/remove/main.go @@ -6,8 +6,8 @@ "sync" "time" - "github.com/vbauerster/mpb/v4" - "github.com/vbauerster/mpb/v4/decor" + "github.com/vbauerster/mpb/v5" + "github.com/vbauerster/mpb/v5/decor" ) func main() { @@ -19,7 +19,8 @@ for i := 0; i < numBars; i++ { name := fmt.Sprintf("Bar#%d:", i) - b := p.AddBar(int64(total), mpb.BarID(i), + bar := p.AddBar(int64(total), + mpb.BarID(i), mpb.BarOptOn(mpb.BarRemoveOnComplete(), func() bool { return i == 0 }), mpb.PrependDecorators( decor.Name(name), @@ -31,15 +32,18 @@ defer wg.Done() rng := rand.New(rand.NewSource(time.Now().UnixNano())) max := 100 * time.Millisecond - for i := 0; !b.Completed(); i++ { + for i := 0; !bar.Completed(); i++ { + // start variable is solely for EWMA calculation + // EWMA's unit of measure is an iteration's taken time start := time.Now() - if b.ID() == 2 && i >= 42 { + if bar.ID() == 2 && i >= 42 { // aborting and removing while bar is running - b.Abort(true) + bar.Abort(true) } time.Sleep(time.Duration(rng.Intn(10)+1) * max / 10) - // since ewma decorator is used, we need to pass time.Since(start) - b.Increment(time.Since(start)) + bar.Increment() + // we need to call DecoratorEwmaUpdate to fulfill ewma decorator's contract + bar.DecoratorEwmaUpdate(time.Since(start)) } }() } diff --git a/_examples/reverseBar/go.mod b/_examples/reverseBar/go.mod index d1a2bf2..87d6b7f 100644 --- a/_examples/reverseBar/go.mod +++ b/_examples/reverseBar/go.mod @@ -1,5 +1,5 @@ module github.com/vbauerster/mpb/_examples/reverseBar -go 1.13 +go 1.14 -require github.com/vbauerster/mpb/v4 v4.12.0 +require github.com/vbauerster/mpb/v5 v5.0.0 diff --git a/_examples/reverseBar/main.go b/_examples/reverseBar/main.go index 95b6e05..67f8343 100644 --- a/_examples/reverseBar/main.go +++ b/_examples/reverseBar/main.go @@ -6,8 +6,8 @@ "sync" "time" - "github.com/vbauerster/mpb/v4" - "github.com/vbauerster/mpb/v4/decor" + "github.com/vbauerster/mpb/v5" + "github.com/vbauerster/mpb/v5/decor" ) func main() { @@ -42,10 +42,13 @@ rng := rand.New(rand.NewSource(time.Now().UnixNano())) max := 100 * time.Millisecond for i := 0; i < total; i++ { + // start variable is solely for EWMA calculation + // EWMA's unit of measure is an iteration's taken time start := time.Now() time.Sleep(time.Duration(rng.Intn(10)+1) * max / 10) - // since ewma decorator is used, we need to pass time.Since(start) - bar.Increment(time.Since(start)) + bar.Increment() + // we need to call DecoratorEwmaUpdate to fulfill ewma decorator's contract + bar.DecoratorEwmaUpdate(time.Since(start)) } }() } diff --git a/_examples/singleBar/go.mod b/_examples/singleBar/go.mod index e80e215..dcbd267 100644 --- a/_examples/singleBar/go.mod +++ b/_examples/singleBar/go.mod @@ -1,5 +1,5 @@ module github.com/vbauerster/mpb/_examples/singleBar -go 1.13 +go 1.14 -require github.com/vbauerster/mpb/v4 v4.12.0 +require github.com/vbauerster/mpb/v5 v5.0.0 diff --git a/_examples/singleBar/main.go b/_examples/singleBar/main.go index 3945e07..3bd305b 100644 --- a/_examples/singleBar/main.go +++ b/_examples/singleBar/main.go @@ -4,8 +4,8 @@ "math/rand" "time" - "github.com/vbauerster/mpb/v4" - "github.com/vbauerster/mpb/v4/decor" + "github.com/vbauerster/mpb/v5" + "github.com/vbauerster/mpb/v5/decor" ) func main() { @@ -32,10 +32,13 @@ // simulating some work max := 100 * time.Millisecond for i := 0; i < total; i++ { + // start variable is solely for EWMA calculation + // EWMA's unit of measure is an iteration's taken time start := time.Now() time.Sleep(time.Duration(rand.Intn(10)+1) * max / 10) - // since ewma decorator is used, we need to pass time.Since(start) - bar.Increment(time.Since(start)) + bar.Increment() + // we need to call DecoratorEwmaUpdate to fulfill ewma decorator's contract + bar.DecoratorEwmaUpdate(time.Since(start)) } // wait for our bar to complete and flush p.Wait() diff --git a/_examples/spinnerBar/go.mod b/_examples/spinnerBar/go.mod index ecdcf97..c64e215 100644 --- a/_examples/spinnerBar/go.mod +++ b/_examples/spinnerBar/go.mod @@ -1,5 +1,5 @@ module github.com/vbauerster/mpb/_examples/spinnerBar -go 1.13 +go 1.14 -require github.com/vbauerster/mpb/v4 v4.12.0 +require github.com/vbauerster/mpb/v5 v5.0.0 diff --git a/_examples/spinnerBar/main.go b/_examples/spinnerBar/main.go index 5ed13dc..bdb3abd 100644 --- a/_examples/spinnerBar/main.go +++ b/_examples/spinnerBar/main.go @@ -6,8 +6,8 @@ "sync" "time" - "github.com/vbauerster/mpb/v4" - "github.com/vbauerster/mpb/v4/decor" + "github.com/vbauerster/mpb/v5" + "github.com/vbauerster/mpb/v5/decor" ) func main() { diff --git a/_examples/spinnerDecorator/go.mod b/_examples/spinnerDecorator/go.mod index 9fadc0b..4c4b26b 100644 --- a/_examples/spinnerDecorator/go.mod +++ b/_examples/spinnerDecorator/go.mod @@ -1,5 +1,5 @@ module github.com/vbauerster/mpb/_examples/spinnerDecorator -go 1.13 +go 1.14 -require github.com/vbauerster/mpb/v4 v4.12.0 +require github.com/vbauerster/mpb/v5 v5.0.0 diff --git a/_examples/spinnerDecorator/main.go b/_examples/spinnerDecorator/main.go index ec55f81..d0499e0 100644 --- a/_examples/spinnerDecorator/main.go +++ b/_examples/spinnerDecorator/main.go @@ -6,8 +6,8 @@ "sync" "time" - "github.com/vbauerster/mpb/v4" - "github.com/vbauerster/mpb/v4/decor" + "github.com/vbauerster/mpb/v5" + "github.com/vbauerster/mpb/v5/decor" ) func main() { diff --git a/_examples/stress/go.mod b/_examples/stress/go.mod index d40b90e..4a1b283 100644 --- a/_examples/stress/go.mod +++ b/_examples/stress/go.mod @@ -1,5 +1,5 @@ module github.com/vbauerster/mpb/_examples/stress -go 1.13 +go 1.14 -require github.com/vbauerster/mpb/v4 v4.12.0 +require github.com/vbauerster/mpb/v5 v5.0.0 diff --git a/_examples/stress/main.go b/_examples/stress/main.go index 2c454a8..ec46fd3 100644 --- a/_examples/stress/main.go +++ b/_examples/stress/main.go @@ -6,8 +6,8 @@ "sync" "time" - "github.com/vbauerster/mpb/v4" - "github.com/vbauerster/mpb/v4/decor" + "github.com/vbauerster/mpb/v5" + "github.com/vbauerster/mpb/v5/decor" ) const ( diff --git a/_examples/suppressBar/go.mod b/_examples/suppressBar/go.mod index 9b9ba42..2771ff5 100644 --- a/_examples/suppressBar/go.mod +++ b/_examples/suppressBar/go.mod @@ -1,5 +1,5 @@ module github.com/vbauerster/mpb/_examples/suppressBar -go 1.13 +go 1.14 -require github.com/vbauerster/mpb/v4 v4.12.0 +require github.com/vbauerster/mpb/v5 v5.0.0 diff --git a/_examples/suppressBar/main.go b/_examples/suppressBar/main.go index b128349..906f2f9 100644 --- a/_examples/suppressBar/main.go +++ b/_examples/suppressBar/main.go @@ -8,8 +8,8 @@ "sync" "time" - "github.com/vbauerster/mpb/v4" - "github.com/vbauerster/mpb/v4/decor" + "github.com/vbauerster/mpb/v5" + "github.com/vbauerster/mpb/v5/decor" ) func main() { @@ -76,21 +76,20 @@ ew.Unlock() } -type customFiller struct { - mpb.Filler - base mpb.Filler +type myBarFiller struct { + mpb.BarFiller + base mpb.BarFiller } -// implementing mpb.WrapFiller, so bar.SetRefill works -func (cf *customFiller) Base() mpb.Filler { +func (cf *myBarFiller) Base() mpb.BarFiller { return cf.base } -func newCustomFiller(ch <-chan string, resume <-chan struct{}) (mpb.Filler, <-chan struct{}) { +func newCustomFiller(ch <-chan string, resume <-chan struct{}) (mpb.BarFiller, <-chan struct{}) { base := mpb.NewBarFiller(mpb.DefaultBarStyle, false) nextCh := make(chan struct{}, 1) var msg *string - filler := func(w io.Writer, width int, st *decor.Statistics) { + filler := mpb.BarFillerFunc(func(w io.Writer, width int, st *decor.Statistics) { select { case m := <-ch: defer func() { @@ -108,10 +107,10 @@ } else { base.Fill(w, width, st) } - } - cf := &customFiller{ - Filler: mpb.FillerFunc(filler), - base: base, + }) + cf := &myBarFiller{ + BarFiller: filler, + base: base, } return cf, nextCh }