Skip to content

Commit

Permalink
lets not divide by zero mkay
Browse files Browse the repository at this point in the history
  • Loading branch information
swartzja committed Dec 15, 2020
1 parent 238d54c commit 9e687bd
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions cmd/utils/stringutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,12 @@ func BuildAsciiMeterCurrentTotal(portion int64, total int64, width int) string {
const fullChar = "█"
const emptyChar = "▒"

ratio := float64(portion) / float64(total)
ratio = math.Max(0, math.Min(1.0, ratio))
full := int(math.Round(ratio * float64(width)))
full := 0
if total > 0 {
ratio := float64(portion) / float64(total)
ratio = math.Max(0, math.Min(1.0, ratio))
full = int(math.Round(ratio * float64(width)))
}

return strings.Join([]string{
strings.Repeat(fullChar, full),
Expand Down

0 comments on commit 9e687bd

Please sign in to comment.