MCPcopy Create free account
hub / github.com/cloudbase/garm / formatSize

Function formatSize

cmd/garm-cli/cmd/file_object.go:574–585  ·  view source on GitHub ↗
(bytes int64)

Source from the content-addressed store, hash-verified

572}
573
574func formatSize(bytes int64) string {
575 const unit = 1024
576 if bytes < unit {
577 return fmt.Sprintf("%d B", bytes)
578 }
579 div, exp := int64(unit), 0
580 for n := bytes / unit; n >= unit; n /= unit {
581 div *= unit
582 exp++
583 }
584 return fmt.Sprintf("%.1f %cB", float64(bytes)/float64(div), "KMGTPE"[exp])
585}

Callers 3

formatFileObjsListFunction · 0.85
controller.goFile · 0.85
formatGARMToolsListFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected