Skip to content

Commit

Permalink
Merge pull request #129 from icey-yu/fix-bar
Browse files Browse the repository at this point in the history
fix: bar length print panic
  • Loading branch information
icey-yu authored Sep 2, 2024
2 parents fef3fe1 + cd89691 commit f2159aa
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion utils/formatutil/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func ProgressBar(name string, progress, total int) string {
barLength = 50
progressLength = int(percentage / 100 * float64(barLength))
}

progressLength = min(progressLength, barLength)
bar := strings.Repeat("█", progressLength) + strings.Repeat(" ", barLength-progressLength)
return fmt.Sprintf("\r%s: [%s] %3.0f%% (%d/%d)", name, bar, percentage, progress, total)
}

0 comments on commit f2159aa

Please sign in to comment.