(b uint64)
| 132 | } |
| 133 | |
| 134 | func humanizeBytes(b uint64) string { |
| 135 | const unit = 1024 |
| 136 | if b < unit { |
| 137 | return fmt.Sprintf("%d B", b) |
| 138 | } |
| 139 | div, exp := uint64(unit), 0 |
| 140 | for n := b / unit; n >= unit; n /= unit { |
| 141 | div *= unit |
| 142 | exp++ |
| 143 | } |
| 144 | return fmt.Sprintf("%.2f %ciB", |
| 145 | float64(b)/float64(div), "KMGTPE"[exp]) |
| 146 | } |