From 08f137aec2ebbbeb637edaab0a720adad74fe3ea Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 15 Apr 2023 12:49:03 +0000 Subject: [PATCH] fix(deps): update module github.com/vbauerster/mpb/v8 to v8.4.0 Signed-off-by: Renovate Bot --- go.mod | 2 +- go.sum | 4 +- vendor/github.com/vbauerster/mpb/v8/README.md | 4 +- .../vbauerster/mpb/v8/decor/counters.go | 188 ++++++++++-------- .../github.com/vbauerster/mpb/v8/decor/eta.go | 3 +- .../vbauerster/mpb/v8/decor/on_abort.go | 3 +- .../vbauerster/mpb/v8/decor/on_complete.go | 3 +- .../vbauerster/mpb/v8/decor/percentage.go | 30 +-- .../vbauerster/mpb/v8/decor/pool.go | 10 - .../vbauerster/mpb/v8/decor/size_type.go | 43 ++-- .../vbauerster/mpb/v8/decor/speed.go | 52 ++--- .../vbauerster/mpb/v8/heap_manager.go | 7 +- .../github.com/vbauerster/mpb/v8/progress.go | 4 +- vendor/modules.txt | 2 +- 14 files changed, 185 insertions(+), 170 deletions(-) delete mode 100644 vendor/github.com/vbauerster/mpb/v8/decor/pool.go diff --git a/go.mod b/go.mod index 7e256ac256..595504292d 100644 --- a/go.mod +++ b/go.mod @@ -58,7 +58,7 @@ require ( github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 github.com/uber/jaeger-client-go v2.30.0+incompatible github.com/ulikunitz/xz v0.5.11 - github.com/vbauerster/mpb/v8 v8.3.0 + github.com/vbauerster/mpb/v8 v8.4.0 github.com/vishvananda/netlink v1.2.1-beta.2 go.etcd.io/bbolt v1.3.7 golang.org/x/net v0.9.0 diff --git a/go.sum b/go.sum index fd70320d1c..132cbdf9c8 100644 --- a/go.sum +++ b/go.sum @@ -987,8 +987,8 @@ github.com/urfave/cli v1.22.12/go.mod h1:sSBEIC79qR6OvcmsD4U3KABeOTxDqQtdDnaFuUN github.com/vbatts/tar-split v0.11.2/go.mod h1:vV3ZuO2yWSVsz+pfFzDG/upWH1JhjOiEaWq6kXyQ3VI= github.com/vbatts/tar-split v0.11.3 h1:hLFqsOLQ1SsppQNTMpkpPXClLDfC2A3Zgy9OUU+RVck= github.com/vbatts/tar-split v0.11.3/go.mod h1:9QlHN18E+fEH7RdG+QAJJcuya3rqT7eXSTY7wGrAokY= -github.com/vbauerster/mpb/v8 v8.3.0 h1:xw2eMJ6v5NP8Rd7yOVzU6OqnRPrS1yWAoLTrWe7W4Nc= -github.com/vbauerster/mpb/v8 v8.3.0/go.mod h1:bngtYUAu25QGxcYYglsF6oyoHlC9Yhh582xF9LjfmL4= +github.com/vbauerster/mpb/v8 v8.4.0 h1:Jq2iNA7T6SydpMVOwaT+2OBWlXS9Th8KEvBqeu5eeTo= +github.com/vbauerster/mpb/v8 v8.4.0/go.mod h1:vjp3hSTuCtR+x98/+2vW3eZ8XzxvGoP8CPseHMhiPyc= github.com/vishvananda/netlink v0.0.0-20181108222139-023a6dafdcdf/go.mod h1:+SR5DhBJrl6ZM7CoCKvpw5BKroDKQ+PJqOg65H/2ktk= github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE= github.com/vishvananda/netlink v1.1.1-0.20201029203352-d40f9887b852/go.mod h1:twkDnbuQxJYemMlGd4JFIcuhgX83tXhKS2B/PRMpOho= diff --git a/vendor/github.com/vbauerster/mpb/v8/README.md b/vendor/github.com/vbauerster/mpb/v8/README.md index d5f7872766..09825ca086 100644 --- a/vendor/github.com/vbauerster/mpb/v8/README.md +++ b/vendor/github.com/vbauerster/mpb/v8/README.md @@ -82,8 +82,8 @@ func main() { mpb.AppendDecorators( // replace ETA decorator with "done" message, OnComplete event decor.OnComplete( - // ETA decorator with ewma age of 60 - decor.EwmaETA(decor.ET_STYLE_GO, 60, decor.WCSyncWidth), "done", + // ETA decorator with ewma age of 30 + decor.EwmaETA(decor.ET_STYLE_GO, 30, decor.WCSyncWidth), "done", ), ), ) diff --git a/vendor/github.com/vbauerster/mpb/v8/decor/counters.go b/vendor/github.com/vbauerster/mpb/v8/decor/counters.go index 331c3df674..0420275783 100644 --- a/vendor/github.com/vbauerster/mpb/v8/decor/counters.go +++ b/vendor/github.com/vbauerster/mpb/v8/decor/counters.go @@ -2,13 +2,6 @@ package decor import ( "fmt" - "strings" -) - -const ( - _ = iota - UnitKiB - UnitKB ) // CountersNoUnit is a wrapper around Counters with no unit param. @@ -17,54 +10,60 @@ func CountersNoUnit(pairFmt string, wcc ...WC) Decorator { } // CountersKibiByte is a wrapper around Counters with predefined unit -// UnitKiB (bytes/1024). +// as SizeB1024(0). func CountersKibiByte(pairFmt string, wcc ...WC) Decorator { - return Counters(UnitKiB, pairFmt, wcc...) + return Counters(SizeB1024(0), pairFmt, wcc...) } // CountersKiloByte is a wrapper around Counters with predefined unit -// UnitKB (bytes/1000). +// as SizeB1000(0). func CountersKiloByte(pairFmt string, wcc ...WC) Decorator { - return Counters(UnitKB, pairFmt, wcc...) + return Counters(SizeB1000(0), pairFmt, wcc...) } // Counters decorator with dynamic unit measure adjustment. // -// `unit` one of [0|UnitKiB|UnitKB] zero for no unit +// `unit` one of [0|SizeB1024(0)|SizeB1000(0)] // -// `pairFmt` printf compatible verbs for current and total pair +// `pairFmt` printf compatible verbs for current and total // // `wcc` optional WC config // -// pairFmt example if unit=UnitKB: +// pairFmt example if unit=SizeB1000(0): // -// pairFmt="%.1f / %.1f" output: "1.0MB / 12.0MB" -// pairFmt="% .1f / % .1f" output: "1.0 MB / 12.0 MB" // pairFmt="%d / %d" output: "1MB / 12MB" // pairFmt="% d / % d" output: "1 MB / 12 MB" -func Counters(unit int, pairFmt string, wcc ...WC) Decorator { - producer := func(unit int, pairFmt string) DecorFunc { - if pairFmt == "" { - pairFmt = "%d / %d" - } else if strings.Count(pairFmt, "%") != 2 { - panic("expected pairFmt with exactly 2 verbs") - } - switch unit { - case UnitKiB: +// pairFmt="%.1f / %.1f" output: "1.0MB / 12.0MB" +// pairFmt="% .1f / % .1f" output: "1.0 MB / 12.0 MB" +// pairFmt="%f / %f" output: "1.000000MB / 12.000000MB" +// pairFmt="% f / % f" output: "1.000000 MB / 12.000000 MB" +func Counters(unit interface{}, pairFmt string, wcc ...WC) Decorator { + producer := func() DecorFunc { + switch unit.(type) { + case SizeB1024: + if pairFmt == "" { + pairFmt = "% d / % d" + } return func(s Statistics) string { return fmt.Sprintf(pairFmt, SizeB1024(s.Current), SizeB1024(s.Total)) } - case UnitKB: + case SizeB1000: + if pairFmt == "" { + pairFmt = "% d / % d" + } return func(s Statistics) string { return fmt.Sprintf(pairFmt, SizeB1000(s.Current), SizeB1000(s.Total)) } default: + if pairFmt == "" { + pairFmt = "%d / %d" + } return func(s Statistics) string { return fmt.Sprintf(pairFmt, s.Current, s.Total) } } } - return Any(producer(unit, pairFmt), wcc...) + return Any(producer(), wcc...) } // TotalNoUnit is a wrapper around Total with no unit param. @@ -73,55 +72,60 @@ func TotalNoUnit(format string, wcc ...WC) Decorator { } // TotalKibiByte is a wrapper around Total with predefined unit -// UnitKiB (bytes/1024). +// as SizeB1024(0). func TotalKibiByte(format string, wcc ...WC) Decorator { - return Total(UnitKiB, format, wcc...) + return Total(SizeB1024(0), format, wcc...) } // TotalKiloByte is a wrapper around Total with predefined unit -// UnitKB (bytes/1000). +// as SizeB1000(0). func TotalKiloByte(format string, wcc ...WC) Decorator { - return Total(UnitKB, format, wcc...) + return Total(SizeB1000(0), format, wcc...) } // Total decorator with dynamic unit measure adjustment. // -// `unit` one of [0|UnitKiB|UnitKB] zero for no unit +// `unit` one of [0|SizeB1024(0)|SizeB1000(0)] // // `format` printf compatible verb for Total // // `wcc` optional WC config // -// format example if unit=UnitKiB: +// format example if unit=SizeB1024(0): // -// format="%.1f" output: "12.0MiB" -// format="% .1f" output: "12.0 MiB" // format="%d" output: "12MiB" // format="% d" output: "12 MiB" -func Total(unit int, format string, wcc ...WC) Decorator { - producer := func(unit int, format string) DecorFunc { - if format == "" { - format = "%d" - } else if strings.Count(format, "%") != 1 { - panic("expected format with exactly 1 verb") - } - - switch unit { - case UnitKiB: +// format="%.1f" output: "12.0MiB" +// format="% .1f" output: "12.0 MiB" +// format="%f" output: "12.000000MiB" +// format="% f" output: "12.000000 MiB" +func Total(unit interface{}, format string, wcc ...WC) Decorator { + producer := func() DecorFunc { + switch unit.(type) { + case SizeB1024: + if format == "" { + format = "% d" + } return func(s Statistics) string { return fmt.Sprintf(format, SizeB1024(s.Total)) } - case UnitKB: + case SizeB1000: + if format == "" { + format = "% d" + } return func(s Statistics) string { return fmt.Sprintf(format, SizeB1000(s.Total)) } default: + if format == "" { + format = "%d" + } return func(s Statistics) string { return fmt.Sprintf(format, s.Total) } } } - return Any(producer(unit, format), wcc...) + return Any(producer(), wcc...) } // CurrentNoUnit is a wrapper around Current with no unit param. @@ -130,55 +134,60 @@ func CurrentNoUnit(format string, wcc ...WC) Decorator { } // CurrentKibiByte is a wrapper around Current with predefined unit -// UnitKiB (bytes/1024). +// as SizeB1024(0). func CurrentKibiByte(format string, wcc ...WC) Decorator { - return Current(UnitKiB, format, wcc...) + return Current(SizeB1024(0), format, wcc...) } // CurrentKiloByte is a wrapper around Current with predefined unit -// UnitKB (bytes/1000). +// as SizeB1000(0). func CurrentKiloByte(format string, wcc ...WC) Decorator { - return Current(UnitKB, format, wcc...) + return Current(SizeB1000(0), format, wcc...) } // Current decorator with dynamic unit measure adjustment. // -// `unit` one of [0|UnitKiB|UnitKB] zero for no unit +// `unit` one of [0|SizeB1024(0)|SizeB1000(0)] // // `format` printf compatible verb for Current // // `wcc` optional WC config // -// format example if unit=UnitKiB: +// format example if unit=SizeB1024(0): // -// format="%.1f" output: "12.0MiB" -// format="% .1f" output: "12.0 MiB" // format="%d" output: "12MiB" // format="% d" output: "12 MiB" -func Current(unit int, format string, wcc ...WC) Decorator { - producer := func(unit int, format string) DecorFunc { - if format == "" { - format = "%d" - } else if strings.Count(format, "%") != 1 { - panic("expected format with exactly 1 verb") - } - - switch unit { - case UnitKiB: +// format="%.1f" output: "12.0MiB" +// format="% .1f" output: "12.0 MiB" +// format="%f" output: "12.000000MiB" +// format="% f" output: "12.000000 MiB" +func Current(unit interface{}, format string, wcc ...WC) Decorator { + producer := func() DecorFunc { + switch unit.(type) { + case SizeB1024: + if format == "" { + format = "% d" + } return func(s Statistics) string { return fmt.Sprintf(format, SizeB1024(s.Current)) } - case UnitKB: + case SizeB1000: + if format == "" { + format = "% d" + } return func(s Statistics) string { return fmt.Sprintf(format, SizeB1000(s.Current)) } default: + if format == "" { + format = "%d" + } return func(s Statistics) string { return fmt.Sprintf(format, s.Current) } } } - return Any(producer(unit, format), wcc...) + return Any(producer(), wcc...) } // InvertedCurrentNoUnit is a wrapper around InvertedCurrent with no unit param. @@ -187,53 +196,58 @@ func InvertedCurrentNoUnit(format string, wcc ...WC) Decorator { } // InvertedCurrentKibiByte is a wrapper around InvertedCurrent with predefined unit -// UnitKiB (bytes/1024). +// as SizeB1024(0). func InvertedCurrentKibiByte(format string, wcc ...WC) Decorator { - return InvertedCurrent(UnitKiB, format, wcc...) + return InvertedCurrent(SizeB1024(0), format, wcc...) } // InvertedCurrentKiloByte is a wrapper around InvertedCurrent with predefined unit -// UnitKB (bytes/1000). +// as SizeB1000(0). func InvertedCurrentKiloByte(format string, wcc ...WC) Decorator { - return InvertedCurrent(UnitKB, format, wcc...) + return InvertedCurrent(SizeB1000(0), format, wcc...) } // InvertedCurrent decorator with dynamic unit measure adjustment. // -// `unit` one of [0|UnitKiB|UnitKB] zero for no unit +// `unit` one of [0|SizeB1024(0)|SizeB1000(0)] // // `format` printf compatible verb for InvertedCurrent // // `wcc` optional WC config // -// format example if unit=UnitKiB: +// format example if unit=SizeB1024(0): // -// format="%.1f" output: "12.0MiB" -// format="% .1f" output: "12.0 MiB" // format="%d" output: "12MiB" // format="% d" output: "12 MiB" -func InvertedCurrent(unit int, format string, wcc ...WC) Decorator { - producer := func(unit int, format string) DecorFunc { - if format == "" { - format = "%d" - } else if strings.Count(format, "%") != 1 { - panic("expected format with exactly 1 verb") - } - - switch unit { - case UnitKiB: +// format="%.1f" output: "12.0MiB" +// format="% .1f" output: "12.0 MiB" +// format="%f" output: "12.000000MiB" +// format="% f" output: "12.000000 MiB" +func InvertedCurrent(unit interface{}, format string, wcc ...WC) Decorator { + producer := func() DecorFunc { + switch unit.(type) { + case SizeB1024: + if format == "" { + format = "% d" + } return func(s Statistics) string { return fmt.Sprintf(format, SizeB1024(s.Total-s.Current)) } - case UnitKB: + case SizeB1000: + if format == "" { + format = "% d" + } return func(s Statistics) string { return fmt.Sprintf(format, SizeB1000(s.Total-s.Current)) } default: + if format == "" { + format = "%d" + } return func(s Statistics) string { return fmt.Sprintf(format, s.Total-s.Current) } } } - return Any(producer(unit, format), wcc...) + return Any(producer(), wcc...) } diff --git a/vendor/github.com/vbauerster/mpb/v8/decor/eta.go b/vendor/github.com/vbauerster/mpb/v8/decor/eta.go index 3594e0185b..e33631dabc 100644 --- a/vendor/github.com/vbauerster/mpb/v8/decor/eta.go +++ b/vendor/github.com/vbauerster/mpb/v8/decor/eta.go @@ -199,8 +199,7 @@ func chooseTimeProducer(style TimeStyle) func(time.Duration) string { } default: return func(remaining time.Duration) string { - // strip off nanoseconds - return ((remaining / time.Second) * time.Second).String() + return remaining.Truncate(time.Second).String() } } } diff --git a/vendor/github.com/vbauerster/mpb/v8/decor/on_abort.go b/vendor/github.com/vbauerster/mpb/v8/decor/on_abort.go index 862ae33d28..65a8d9daec 100644 --- a/vendor/github.com/vbauerster/mpb/v8/decor/on_abort.go +++ b/vendor/github.com/vbauerster/mpb/v8/decor/on_abort.go @@ -34,8 +34,7 @@ type onAbortWrapper struct { func (d *onAbortWrapper) Decor(s Statistics) string { if s.Aborted { - wc := d.GetConf() - return wc.FormatMsg(d.msg) + return d.GetConf().FormatMsg(d.msg) } return d.Decorator.Decor(s) } diff --git a/vendor/github.com/vbauerster/mpb/v8/decor/on_complete.go b/vendor/github.com/vbauerster/mpb/v8/decor/on_complete.go index 6ee9268448..0a3897b818 100644 --- a/vendor/github.com/vbauerster/mpb/v8/decor/on_complete.go +++ b/vendor/github.com/vbauerster/mpb/v8/decor/on_complete.go @@ -33,8 +33,7 @@ type onCompleteWrapper struct { func (d *onCompleteWrapper) Decor(s Statistics) string { if s.Completed { - wc := d.GetConf() - return wc.FormatMsg(d.msg) + return d.GetConf().FormatMsg(d.msg) } return d.Decorator.Decor(s) } diff --git a/vendor/github.com/vbauerster/mpb/v8/decor/percentage.go b/vendor/github.com/vbauerster/mpb/v8/decor/percentage.go index 1d3b3a9e00..9709c196cc 100644 --- a/vendor/github.com/vbauerster/mpb/v8/decor/percentage.go +++ b/vendor/github.com/vbauerster/mpb/v8/decor/percentage.go @@ -7,24 +7,25 @@ import ( "github.com/vbauerster/mpb/v8/internal" ) +var _ fmt.Formatter = percentageType(0) + type percentageType float64 func (s percentageType) Format(st fmt.State, verb rune) { - var prec int + prec := -1 switch verb { - case 'd': - case 's': - prec = -1 - default: + case 'f', 'e', 'E': + prec = 6 // default prec of fmt.Printf("%f|%e|%E") + fallthrough + case 'b', 'g', 'G', 'x', 'X': if p, ok := st.Precision(); ok { prec = p - } else { - prec = 6 } + default: + verb, prec = 'f', 0 } - p := bytesPool.Get().(*[]byte) - b := strconv.AppendFloat(*p, float64(s), 'f', prec, 64) + b := strconv.AppendFloat(make([]byte, 0, 16), float64(s), byte(verb), prec, 64) if st.Flag(' ') { b = append(b, ' ', '%') } else { @@ -34,7 +35,6 @@ func (s percentageType) Format(st fmt.State, verb rune) { if err != nil { panic(err) } - bytesPool.Put(p) } // Percentage returns percentage decorator. It's a wrapper of NewPercentage. @@ -44,12 +44,18 @@ func Percentage(wcc ...WC) Decorator { // NewPercentage percentage decorator with custom format string. // +// `format` printf compatible verb +// +// `wcc` optional WC config +// // format examples: // -// format="%.1f" output: "1.0%" -// format="% .1f" output: "1.0 %" // format="%d" output: "1%" // format="% d" output: "1 %" +// format="%.1f" output: "1.0%" +// format="% .1f" output: "1.0 %" +// format="%f" output: "1.000000%" +// format="% f" output: "1.000000 %" func NewPercentage(format string, wcc ...WC) Decorator { if format == "" { format = "% d" diff --git a/vendor/github.com/vbauerster/mpb/v8/decor/pool.go b/vendor/github.com/vbauerster/mpb/v8/decor/pool.go deleted file mode 100644 index cefa9bfac2..0000000000 --- a/vendor/github.com/vbauerster/mpb/v8/decor/pool.go +++ /dev/null @@ -1,10 +0,0 @@ -package decor - -import "sync" - -var bytesPool = sync.Pool{ - New: func() interface{} { - b := make([]byte, 0, 32) - return &b - }, -} diff --git a/vendor/github.com/vbauerster/mpb/v8/decor/size_type.go b/vendor/github.com/vbauerster/mpb/v8/decor/size_type.go index 4df27095f3..d9950b61c9 100644 --- a/vendor/github.com/vbauerster/mpb/v8/decor/size_type.go +++ b/vendor/github.com/vbauerster/mpb/v8/decor/size_type.go @@ -8,6 +8,13 @@ import ( //go:generate stringer -type=SizeB1024 -trimprefix=_i //go:generate stringer -type=SizeB1000 -trimprefix=_ +var ( + _ fmt.Formatter = SizeB1024(0) + _ fmt.Stringer = SizeB1024(0) + _ fmt.Formatter = SizeB1000(0) + _ fmt.Stringer = SizeB1000(0) +) + const ( _ib SizeB1024 = iota + 1 _iKiB SizeB1024 = 1 << (iota * 10) @@ -22,17 +29,17 @@ const ( type SizeB1024 int64 func (self SizeB1024) Format(st fmt.State, verb rune) { - var prec int + prec := -1 switch verb { - case 'd': - case 's': - prec = -1 - default: + case 'f', 'e', 'E': + prec = 6 // default prec of fmt.Printf("%f|%e|%E") + fallthrough + case 'b', 'g', 'G', 'x', 'X': if p, ok := st.Precision(); ok { prec = p - } else { - prec = 6 } + default: + verb, prec = 'f', 0 } var unit SizeB1024 @@ -49,8 +56,7 @@ func (self SizeB1024) Format(st fmt.State, verb rune) { unit = _iTiB } - p := bytesPool.Get().(*[]byte) - b := strconv.AppendFloat(*p, float64(self)/float64(unit), 'f', prec, 64) + b := strconv.AppendFloat(make([]byte, 0, 24), float64(self)/float64(unit), byte(verb), prec, 64) if st.Flag(' ') { b = append(b, ' ') } @@ -59,7 +65,6 @@ func (self SizeB1024) Format(st fmt.State, verb rune) { if err != nil { panic(err) } - bytesPool.Put(p) } const ( @@ -76,17 +81,17 @@ const ( type SizeB1000 int64 func (self SizeB1000) Format(st fmt.State, verb rune) { - var prec int + prec := -1 switch verb { - case 'd': - case 's': - prec = -1 - default: + case 'f', 'e', 'E': + prec = 6 // default prec of fmt.Printf("%f|%e|%E") + fallthrough + case 'b', 'g', 'G', 'x', 'X': if p, ok := st.Precision(); ok { prec = p - } else { - prec = 6 } + default: + verb, prec = 'f', 0 } var unit SizeB1000 @@ -103,8 +108,7 @@ func (self SizeB1000) Format(st fmt.State, verb rune) { unit = _TB } - p := bytesPool.Get().(*[]byte) - b := strconv.AppendFloat(*p, float64(self)/float64(unit), 'f', prec, 64) + b := strconv.AppendFloat(make([]byte, 0, 24), float64(self)/float64(unit), byte(verb), prec, 64) if st.Flag(' ') { b = append(b, ' ') } @@ -113,5 +117,4 @@ func (self SizeB1000) Format(st fmt.State, verb rune) { if err != nil { panic(err) } - bytesPool.Put(p) } diff --git a/vendor/github.com/vbauerster/mpb/v8/decor/speed.go b/vendor/github.com/vbauerster/mpb/v8/decor/speed.go index dd0ad70014..d4f644704f 100644 --- a/vendor/github.com/vbauerster/mpb/v8/decor/speed.go +++ b/vendor/github.com/vbauerster/mpb/v8/decor/speed.go @@ -39,7 +39,7 @@ func (self speedFormatter) Format(st fmt.State, verb rune) { // EwmaSpeed exponential-weighted-moving-average based speed decorator. // For this decorator to work correctly you have to measure each iteration's // duration and pass it to one of the (*Bar).EwmaIncr... family methods. -func EwmaSpeed(unit int, format string, age float64, wcc ...WC) Decorator { +func EwmaSpeed(unit interface{}, format string, age float64, wcc ...WC) Decorator { var average ewma.MovingAverage if age == 0 { average = ewma.NewMovingAverage() @@ -52,7 +52,7 @@ func EwmaSpeed(unit int, format string, age float64, wcc ...WC) Decorator { // MovingAverageSpeed decorator relies on MovingAverage implementation // to calculate its average. // -// `unit` one of [0|UnitKiB|UnitKB] zero for no unit +// `unit` one of [0|SizeB1024(0)|SizeB1000(0)] // // `format` printf compatible verb for value, like "%f" or "%d" // @@ -62,14 +62,11 @@ func EwmaSpeed(unit int, format string, age float64, wcc ...WC) Decorator { // // format examples: // -// unit=UnitKiB, format="%.1f" output: "1.0MiB/s" -// unit=UnitKiB, format="% .1f" output: "1.0 MiB/s" -// unit=UnitKB, format="%.1f" output: "1.0MB/s" -// unit=UnitKB, format="% .1f" output: "1.0 MB/s" -func MovingAverageSpeed(unit int, format string, average ewma.MovingAverage, wcc ...WC) Decorator { - if format == "" { - format = "%.0f" - } +// unit=SizeB1024(0), format="%.1f" output: "1.0MiB/s" +// unit=SizeB1024(0), format="% .1f" output: "1.0 MiB/s" +// unit=SizeB1000(0), format="%.1f" output: "1.0MB/s" +// unit=SizeB1000(0), format="% .1f" output: "1.0 MB/s" +func MovingAverageSpeed(unit interface{}, format string, average ewma.MovingAverage, wcc ...WC) Decorator { d := &movingAverageSpeed{ WC: initWC(wcc...), average: average, @@ -106,14 +103,14 @@ func (d *movingAverageSpeed) EwmaUpdate(n int64, dur time.Duration) { // AverageSpeed decorator with dynamic unit measure adjustment. It's // a wrapper of NewAverageSpeed. -func AverageSpeed(unit int, format string, wcc ...WC) Decorator { +func AverageSpeed(unit interface{}, format string, wcc ...WC) Decorator { return NewAverageSpeed(unit, format, time.Now(), wcc...) } // NewAverageSpeed decorator with dynamic unit measure adjustment and // user provided start time. // -// `unit` one of [0|UnitKiB|UnitKB] zero for no unit +// `unit` one of [0|SizeB1024(0)|SizeB1000(0)] // // `format` printf compatible verb for value, like "%f" or "%d" // @@ -123,14 +120,11 @@ func AverageSpeed(unit int, format string, wcc ...WC) Decorator { // // format examples: // -// unit=UnitKiB, format="%.1f" output: "1.0MiB/s" -// unit=UnitKiB, format="% .1f" output: "1.0 MiB/s" -// unit=UnitKB, format="%.1f" output: "1.0MB/s" -// unit=UnitKB, format="% .1f" output: "1.0 MB/s" -func NewAverageSpeed(unit int, format string, startTime time.Time, wcc ...WC) Decorator { - if format == "" { - format = "%.0f" - } +// unit=SizeB1024(0), format="%.1f" output: "1.0MiB/s" +// unit=SizeB1024(0), format="% .1f" output: "1.0 MiB/s" +// unit=SizeB1000(0), format="%.1f" output: "1.0MB/s" +// unit=SizeB1000(0), format="% .1f" output: "1.0 MB/s" +func NewAverageSpeed(unit interface{}, format string, startTime time.Time, wcc ...WC) Decorator { d := &averageSpeed{ WC: initWC(wcc...), startTime: startTime, @@ -151,7 +145,6 @@ func (d *averageSpeed) Decor(s Statistics) string { speed := float64(s.Current) / float64(time.Since(d.startTime)) d.msg = d.producer(speed * 1e9) } - return d.FormatMsg(d.msg) } @@ -159,17 +152,26 @@ func (d *averageSpeed) AverageAdjust(startTime time.Time) { d.startTime = startTime } -func chooseSpeedProducer(unit int, format string) func(float64) string { - switch unit { - case UnitKiB: +func chooseSpeedProducer(unit interface{}, format string) func(float64) string { + switch unit.(type) { + case SizeB1024: + if format == "" { + format = "% d" + } return func(speed float64) string { return fmt.Sprintf(format, FmtAsSpeed(SizeB1024(math.Round(speed)))) } - case UnitKB: + case SizeB1000: + if format == "" { + format = "% d" + } return func(speed float64) string { return fmt.Sprintf(format, FmtAsSpeed(SizeB1000(math.Round(speed)))) } default: + if format == "" { + format = "%f" + } return func(speed float64) string { return fmt.Sprintf(format, speed) } diff --git a/vendor/github.com/vbauerster/mpb/v8/heap_manager.go b/vendor/github.com/vbauerster/mpb/v8/heap_manager.go index 678dd7c9f3..1b2364f770 100644 --- a/vendor/github.com/vbauerster/mpb/v8/heap_manager.go +++ b/vendor/github.com/vbauerster/mpb/v8/heap_manager.go @@ -46,6 +46,7 @@ func (m heapManager) run() { var sync bool for req := range m { + next: switch req.cmd { case h_push: data := req.data.(pushData) @@ -78,7 +79,8 @@ func (m heapManager) run() { select { case data.iter <- b: case <-data.drop: - break + close(data.iter) + break next } } close(data.iter) @@ -88,7 +90,8 @@ func (m heapManager) run() { select { case data.iter <- heap.Pop(&bHeap).(*Bar): case <-data.drop: - break + close(data.iter) + break next } } close(data.iter) diff --git a/vendor/github.com/vbauerster/mpb/v8/progress.go b/vendor/github.com/vbauerster/mpb/v8/progress.go index 9bb557ee45..cc4e3e1022 100644 --- a/vendor/github.com/vbauerster/mpb/v8/progress.go +++ b/vendor/github.com/vbauerster/mpb/v8/progress.go @@ -19,7 +19,7 @@ const ( ) // DoneError represents an error when `*mpb.Progress` is done but its functionality is requested. -var DoneError = fmt.Errorf("%T instance can't be reused after it's done!", (*Progress)(nil)) +var DoneError = fmt.Errorf("%T instance can't be reused after it's done", (*Progress)(nil)) // Progress represents a container that renders one or more progress bars. type Progress struct { @@ -351,7 +351,7 @@ func (s *pState) render(cw *cwriter.Writer) (err error) { } func (s *pState) flush(cw *cwriter.Writer, height int) error { - wg := new(sync.WaitGroup) + var wg sync.WaitGroup defer wg.Wait() // waiting for all s.hm.push to complete var popCount int diff --git a/vendor/modules.txt b/vendor/modules.txt index 34680d0cee..4a6ea7d86a 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -878,7 +878,7 @@ github.com/ulikunitz/xz/lzma github.com/vbatts/tar-split/archive/tar github.com/vbatts/tar-split/tar/asm github.com/vbatts/tar-split/tar/storage -# github.com/vbauerster/mpb/v8 v8.3.0 +# github.com/vbauerster/mpb/v8 v8.4.0 ## explicit; go 1.17 github.com/vbauerster/mpb/v8 github.com/vbauerster/mpb/v8/cwriter