formatBytes formats bytes into human-readable format
(bytes int64)
| 211 | |
| 212 | // formatBytes formats bytes into human-readable format |
| 213 | func formatBytes(bytes int64) string { |
| 214 | const unit = 1024 |
| 215 | if bytes < unit { |
| 216 | return strconv.FormatInt(bytes, 10) + " B" |
| 217 | } |
| 218 | div, exp := int64(unit), 0 |
| 219 | for n := bytes / unit; n >= unit; n /= unit { |
| 220 | div *= unit |
| 221 | exp++ |
| 222 | } |
| 223 | units := []string{"KB", "MB", "GB", "TB"} |
| 224 | return strconv.FormatFloat(float64(bytes)/float64(div), 'f', 2, 64) + " " + units[exp] |
| 225 | } |
| 226 | |
| 227 | // resizeColUnsafe adjusts the number of columns (must be called with lock held) |
| 228 | // Fills missing columns with "NaN" |
no outgoing calls