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

Function humanBytes

internal/exit/stats.go:58–70  ·  view source on GitHub ↗

humanBytes formats a byte count as a short human-readable string. Mirrors the carrier's helper but kept package-local to avoid an inter-package dependency just for one tiny formatter.

(n uint64)

Source from the content-addressed store, hash-verified

56// the carrier's helper but kept package-local to avoid an inter-package
57// dependency just for one tiny formatter.
58func humanBytes(n uint64) string {
59 const k = 1024
60 switch {
61 case n < k:
62 return fmt.Sprintf("%dB", n)
63 case n < k*k:
64 return fmt.Sprintf("%.1fKB", float64(n)/float64(k))
65 case n < k*k*k:
66 return fmt.Sprintf("%.1fMB", float64(n)/float64(k*k))
67 default:
68 return fmt.Sprintf("%.2fGB", float64(n)/float64(k*k*k))
69 }
70}

Callers 1

logStatsMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected