MCPcopy Create free account
hub / github.com/Hidden-Node/GooseRelayVPN-AndroidClient / humanBytes

Function humanBytes

internal/carrier/stats.go:175–187  ·  view source on GitHub ↗

humanBytes formats a byte count as a short human-readable string. Used for stats lines that an operator scans visually.

(n uint64)

Source from the content-addressed store, hash-verified

173// humanBytes formats a byte count as a short human-readable string. Used for
174// stats lines that an operator scans visually.
175func humanBytes(n uint64) string {
176 const k = 1024
177 switch {
178 case n < k:
179 return fmt.Sprintf("%dB", n)
180 case n < k*k:
181 return fmt.Sprintf("%.1fKB", float64(n)/float64(k))
182 case n < k*k*k:
183 return fmt.Sprintf("%.1fMB", float64(n)/float64(k*k))
184 default:
185 return fmt.Sprintf("%.2fGB", float64(n)/float64(k*k*k))
186 }
187}

Callers 1

logStatsMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected