progress: fix bar rate

This commit is contained in:
Michael Yang
2023-11-18 16:23:03 -08:00
parent e1a69d44c9
commit 424d53ac70
3 changed files with 125 additions and 81 deletions

View File

@@ -40,8 +40,8 @@ func (s *Spinner) String() string {
}
fmt.Fprintf(&sb, "%s", message)
if s.messageWidth-sb.Len() >= 0 {
sb.WriteString(strings.Repeat(" ", s.messageWidth-sb.Len()))
if padding := s.messageWidth - sb.Len(); padding > 0 {
sb.WriteString(strings.Repeat(" ", padding))
}
sb.WriteString(" ")