(b uint64)
| 97 | } |
| 98 | |
| 99 | func formatBytes(b uint64) string { |
| 100 | const unit = 1024 |
| 101 | if b < unit { |
| 102 | return fmt.Sprintf("%d B", b) |
| 103 | } |
| 104 | div, exp := uint64(unit), 0 |
| 105 | for n := b / unit; n >= unit; n /= unit { |
| 106 | div *= unit |
| 107 | exp++ |
| 108 | } |
| 109 | return fmt.Sprintf("%.1f %ciB", float64(b)/float64(div), "KMGTPE"[exp]) |
| 110 | } |
no outgoing calls
no test coverage detected