(text string, currentBytes int64, totalBytes int64, bytesPerSecond int64)
| 71 | } |
| 72 | |
| 73 | func (b *ProgressBar) renderProgress(text string, currentBytes int64, totalBytes int64, bytesPerSecond int64) int { |
| 74 | percent := math.Min(float64(currentBytes)/float64(totalBytes)*100.0, 100.0) |
| 75 | bar := b.createBar(percent) |
| 76 | totalBytesFormatted, unit := b.formatBytes(totalBytes) |
| 77 | currentBytesFormatted, unit := b.formatBytesInUnit(currentBytes, unit) |
| 78 | bytesPerSecondFormatted, bytesPerSecondUnit := b.formatBytes(bytesPerSecond) |
| 79 | output := fmt.Sprintf("%s %3d%% |%s| (%s/%s %s, %s %s/s)", |
| 80 | text, |
| 81 | int(percent), |
| 82 | bar, |
| 83 | currentBytesFormatted, |
| 84 | totalBytesFormatted, |
| 85 | unit, |
| 86 | bytesPerSecondFormatted, |
| 87 | bytesPerSecondUnit) |
| 88 | b.logger.LogError(output) |
| 89 | return utf8.RuneCountInString(output) |
| 90 | } |
| 91 | |
| 92 | func (b *ProgressBar) createBar(percent float64) string { |
| 93 | barCount := int(percent / 5.0) |
no test coverage detected