diff --git a/decor/counters.go b/decor/counters.go index c5a6783..e4161dc 100644 --- a/decor/counters.go +++ b/decor/counters.go @@ -178,14 +178,14 @@ type countersDecorator struct { WC - unit int - pairFormat string - complete *completeMsg + unit int + pairFormat string + completeMsg *string } func (d *countersDecorator) Decor(st *Statistics) string { - if st.Completed && d.complete != nil { - return d.FormatMsg(d.complete.msg) + if st.Completed && d.completeMsg != nil { + return d.FormatMsg(*d.completeMsg) } var str string @@ -202,5 +202,5 @@ } func (d *countersDecorator) OnCompleteMessage(msg string) { - d.complete = &completeMsg{msg} -} + d.completeMsg = &msg +} diff --git a/decor/decorator.go b/decor/decorator.go index 0a395ec..6aaf6c8 100644 --- a/decor/decorator.go +++ b/decor/decorator.go @@ -142,8 +142,3 @@ } return decorator } - -// completeMsg for internal usage. -type completeMsg struct { - msg string -} diff --git a/decor/elapsed.go b/decor/elapsed.go index 9b510d7..6e635f5 100644 --- a/decor/elapsed.go +++ b/decor/elapsed.go @@ -26,14 +26,14 @@ type elapsedDecorator struct { WC - style int - startTime time.Time - complete *completeMsg + style int + startTime time.Time + completeMsg *string } func (d *elapsedDecorator) Decor(st *Statistics) string { - if st.Completed && d.complete != nil { - return d.FormatMsg(d.complete.msg) + if st.Completed && d.completeMsg != nil { + return d.FormatMsg(*d.completeMsg) } var str string @@ -57,5 +57,5 @@ } func (d *elapsedDecorator) OnCompleteMessage(msg string) { - d.complete = &completeMsg{msg} + d.completeMsg = &msg } diff --git a/decor/eta.go b/decor/eta.go index 9ebbf32..21ef4b2 100644 --- a/decor/eta.go +++ b/decor/eta.go @@ -43,14 +43,14 @@ type movingAverageETA struct { WC - style int - average ewma.MovingAverage - complete *completeMsg + style int + average ewma.MovingAverage + completeMsg *string } func (d *movingAverageETA) Decor(st *Statistics) string { - if st.Completed && d.complete != nil { - return d.FormatMsg(d.complete.msg) + if st.Completed && d.completeMsg != nil { + return d.FormatMsg(*d.completeMsg) } v := internal.Round(d.average.Value()) @@ -87,7 +87,7 @@ } func (d *movingAverageETA) OnCompleteMessage(msg string) { - d.complete = &completeMsg{msg} + d.completeMsg = &msg } // AverageETA decorator. @@ -111,14 +111,14 @@ type averageETA struct { WC - style int - startTime time.Time - complete *completeMsg + style int + startTime time.Time + completeMsg *string } func (d *averageETA) Decor(st *Statistics) string { - if st.Completed && d.complete != nil { - return d.FormatMsg(d.complete.msg) + if st.Completed && d.completeMsg != nil { + return d.FormatMsg(*d.completeMsg) } var str string @@ -147,5 +147,5 @@ } func (d *averageETA) OnCompleteMessage(msg string) { - d.complete = &completeMsg{msg} + d.completeMsg = &msg } diff --git a/decor/name.go b/decor/name.go index 9096862..a5a5d14 100644 --- a/decor/name.go +++ b/decor/name.go @@ -30,16 +30,16 @@ type nameDecorator struct { WC msg string - complete *completeMsg + complete *string } func (d *nameDecorator) Decor(st *Statistics) string { if st.Completed && d.complete != nil { - return d.FormatMsg(d.complete.msg) + return d.FormatMsg(*d.complete) } return d.FormatMsg(d.msg) } func (d *nameDecorator) OnCompleteMessage(msg string) { - d.complete = &completeMsg{msg} + d.complete = &msg } diff --git a/decor/percentage.go b/decor/percentage.go index 34bd81f..078fbcf 100644 --- a/decor/percentage.go +++ b/decor/percentage.go @@ -23,17 +23,17 @@ type percentageDecorator struct { WC - complete *completeMsg + completeMsg *string } func (d *percentageDecorator) Decor(st *Statistics) string { - if st.Completed && d.complete != nil { - return d.FormatMsg(d.complete.msg) + if st.Completed && d.completeMsg != nil { + return d.FormatMsg(*d.completeMsg) } str := fmt.Sprintf("%d %%", internal.Percentage(st.Total, st.Current, 100)) return d.FormatMsg(str) } func (d *percentageDecorator) OnCompleteMessage(msg string) { - d.complete = &completeMsg{msg} + d.completeMsg = &msg } diff --git a/decor/speed.go b/decor/speed.go index 14d683d..44cf011 100644 --- a/decor/speed.go +++ b/decor/speed.go @@ -162,17 +162,17 @@ type movingAverageSpeed struct { WC - unit int - unitFormat string - average ewma.MovingAverage - msg string - complete *completeMsg + unit int + unitFormat string + average ewma.MovingAverage + msg string + completeMsg *string } func (d *movingAverageSpeed) Decor(st *Statistics) string { if st.Completed { - if d.complete != nil { - return d.FormatMsg(d.complete.msg) + if d.completeMsg != nil { + return d.FormatMsg(*d.completeMsg) } return d.FormatMsg(d.msg) } @@ -200,7 +200,7 @@ } func (d *movingAverageSpeed) OnCompleteMessage(msg string) { - d.complete = &completeMsg{msg} + d.completeMsg = &msg } // AverageSpeed decorator with dynamic unit measure adjustment. @@ -231,17 +231,17 @@ type averageSpeed struct { WC - unit int - unitFormat string - startTime time.Time - msg string - complete *completeMsg + unit int + unitFormat string + startTime time.Time + msg string + completeMsg *string } func (d *averageSpeed) Decor(st *Statistics) string { if st.Completed { - if d.complete != nil { - return d.FormatMsg(d.complete.msg) + if d.completeMsg != nil { + return d.FormatMsg(*d.completeMsg) } return d.FormatMsg(d.msg) } @@ -262,5 +262,5 @@ } func (d *averageSpeed) OnCompleteMessage(msg string) { - d.complete = &completeMsg{msg} -} + d.completeMsg = &msg +}