diff --git a/decor/eta.go b/decor/eta.go index e33631d..ecb6f8f 100644 --- a/decor/eta.go +++ b/decor/eta.go @@ -68,13 +68,13 @@ producer func(time.Duration) string } -func (d *movingAverageETA) Decor(s Statistics) string { +func (d *movingAverageETA) Decor(s Statistics) (string, int) { v := math.Round(d.average.Value()) remaining := time.Duration((s.Total - s.Current) * int64(v)) if d.normalizer != nil { remaining = d.normalizer.Normalize(remaining) } - return d.FormatMsg(d.producer(remaining)) + return d.Format(d.producer(remaining)) } func (d *movingAverageETA) EwmaUpdate(n int64, dur time.Duration) { @@ -120,7 +120,7 @@ producer func(time.Duration) string } -func (d *averageETA) Decor(s Statistics) string { +func (d *averageETA) Decor(s Statistics) (string, int) { var remaining time.Duration if s.Current != 0 { durPerItem := float64(time.Since(d.startTime)) / float64(s.Current) @@ -130,7 +130,7 @@ remaining = d.normalizer.Normalize(remaining) } } - return d.FormatMsg(d.producer(remaining)) + return d.Format(d.producer(remaining)) } func (d *averageETA) AverageAdjust(startTime time.Time) { diff --git a/decor/speed.go b/decor/speed.go index d4f6447..5879d06 100644 --- a/decor/speed.go +++ b/decor/speed.go @@ -82,7 +82,7 @@ msg string } -func (d *movingAverageSpeed) Decor(s Statistics) string { +func (d *movingAverageSpeed) Decor(s Statistics) (string, int) { if !s.Completed { var speed float64 if v := d.average.Value(); v > 0 { @@ -90,7 +90,7 @@ } d.msg = d.producer(speed * 1e9) } - return d.FormatMsg(d.msg) + return d.Format(d.msg) } func (d *movingAverageSpeed) EwmaUpdate(n int64, dur time.Duration) { @@ -140,12 +140,12 @@ msg string } -func (d *averageSpeed) Decor(s Statistics) string { +func (d *averageSpeed) Decor(s Statistics) (string, int) { if !s.Completed { speed := float64(s.Current) / float64(time.Since(d.startTime)) d.msg = d.producer(speed * 1e9) } - return d.FormatMsg(d.msg) + return d.Format(d.msg) } func (d *averageSpeed) AverageAdjust(startTime time.Time) { diff --git a/decor/speed_test.go b/decor/speed_test.go index 5de432a..2fe770b 100644 --- a/decor/speed_test.go +++ b/decor/speed_test.go @@ -133,7 +133,7 @@ stat := Statistics{ Current: tc.current, } - res := decor.Decor(stat) + res, _ := decor.Decor(stat) if res != tc.expected { t.Fatalf("expected: %q, got: %q\n", tc.expected, res) } @@ -269,7 +269,7 @@ stat := Statistics{ Current: tc.current, } - res := decor.Decor(stat) + res, _ := decor.Decor(stat) if res != tc.expected { t.Fatalf("expected: %q, got: %q\n", tc.expected, res) } diff --git a/decorators_test.go b/decorators_test.go index 12927ef..56e7a4b 100644 --- a/decorators_test.go +++ b/decorators_test.go @@ -31,7 +31,7 @@ } for _, test := range tests { - got := test.decorator.Decor(decor.Statistics{}) + got, _ := test.decorator.Decor(decor.Statistics{}) if got != test.want { t.Errorf("Want: %q, Got: %q\n", test.want, got) } @@ -188,7 +188,8 @@ step := step ch := make(chan string) go func() { - ch <- step.decorator.Decor(step.stat) + str, _ := step.decorator.Decor(step.stat) + ch <- str }() results = append(results, ch) }