make PercentageType private
Vladimir Bauer
6 years ago
| 7 | 7 | "github.com/vbauerster/mpb/v4/internal" |
| 8 | 8 | ) |
| 9 | 9 | |
| 10 | // PercentageType named type, which implements fmt.Formatter interface. | |
| 11 | // It appends `%` sign to its value. | |
| 12 | type PercentageType float64 | |
| 10 | type percentageType float64 | |
| 13 | 11 | |
| 14 | func (s PercentageType) Format(st fmt.State, verb rune) { | |
| 12 | func (s percentageType) Format(st fmt.State, verb rune) { | |
| 15 | 13 | var prec int |
| 16 | 14 | switch verb { |
| 17 | 15 | case 'd': |
| 74 | 72 | return d.FormatMsg(*d.completeMsg) |
| 75 | 73 | } |
| 76 | 74 | p := internal.Percentage(st.Total, st.Current, 100) |
| 77 | return d.FormatMsg(fmt.Sprintf(d.fmt, PercentageType(p))) | |
| 75 | return d.FormatMsg(fmt.Sprintf(d.fmt, percentageType(p))) | |
| 78 | 76 | } |
| 79 | 77 | |
| 80 | 78 | func (d *percentageDecorator) OnCompleteMessage(msg string) { |