MCPcopy Create free account
hub / github.com/arshamalh/dockeroller / SizeToHumanReadable

Function SizeToHumanReadable

tools/human_readable_units.go:5–14  ·  view source on GitHub ↗
(size int64)

Source from the content-addressed store, hash-verified

3import "fmt"
4
5func SizeToHumanReadable(size int64) string {
6 if size/1e9 > 0 {
7 return fmt.Sprintf("%.2f GigaBytes", float32(size)/1e9)
8 } else if size/1e6 > 0 {
9 return fmt.Sprintf("%.2f MegaBytes", float32(size)/1e6)
10 } else if size/1e3 > 0 {
11 return fmt.Sprintf("%.2f KiloBytes", float32(size)/1e3)
12 }
13 return fmt.Sprintf("%d Bytes", size)
14}

Callers 3

FmtImageFunction · 0.92
FmtStatsFunction · 0.92
TestSizeToHumanReadableFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestSizeToHumanReadableFunction · 0.68