formatBytes converts bytes to human-readable format (KB, MB, GB)
(bytes int64)
| 4 | |
| 5 | // formatBytes converts bytes to human-readable format (KB, MB, GB) |
| 6 | func formatBytes(bytes int64) string { |
| 7 | value, unit := scaleBinaryBytes(bytes, []string{"KB", "MB", "GB"}) |
| 8 | if unit == "B" { |
| 9 | return fmt.Sprintf("%dB", bytes) |
| 10 | } |
| 11 | if unit == "GB" { |
| 12 | return fmt.Sprintf("%.2fGB", value) |
| 13 | } |
| 14 | return fmt.Sprintf("%.1f%s", value, unit) |
| 15 | } |