internal make sure width is uint
Vladimir Bauer
4 years ago
| 2 | 2 | import "math" |
| 3 | 3 | |
| 4 | 4 | // Percentage is a helper function, to calculate percentage. |
| 5 | func Percentage(total, current int64, width int) float64 { | |
| 5 | func Percentage(total, current int64, width uint) float64 { | |
| 6 | 6 | if total <= 0 { |
| 7 | 7 | return 0 |
| 8 | 8 | } |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | // PercentageRound same as Percentage but with math.Round. |
| 16 | func PercentageRound(total, current int64, width int) float64 { | |
| 16 | func PercentageRound(total, current int64, width uint) float64 { | |
| 17 | 17 | return math.Round(Percentage(total, current, width)) |
| 18 | 18 | } |