MCPcopy Create free account
hub / github.com/diillson/chatcli / formatBytes

Function formatBytes

cli/command_handler_metrics.go:99–110  ·  view source on GitHub ↗
(b uint64)

Source from the content-addressed store, hash-verified

97}
98
99func 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}

Callers 1

handleMetricsCommandMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected