MCPcopy Create free account
hub / github.com/ECSTeam/cloudfoundry-top-plugin / StringWithPrecision

Method StringWithPrecision

util/bytesize.go:41–64  ·  view source on GitHub ↗
(precision int)

Source from the content-addressed store, hash-verified

39}
40
41func (b ByteSize) StringWithPrecision(precision int) string {
42
43 format := fmt.Sprintf("%%.%vf", precision)
44
45 switch {
46 case b >= YB:
47 return fmt.Sprintf(format+"YB", b/YB)
48 case b >= ZB:
49 return fmt.Sprintf(format+"ZB", b/ZB)
50 case b >= EB:
51 return fmt.Sprintf(format+"EB", b/EB)
52 case b >= PB:
53 return fmt.Sprintf(format+"PB", b/PB)
54 case b >= TB:
55 return fmt.Sprintf(format+"TB", b/TB)
56 case b >= GB:
57 return fmt.Sprintf(format+"GB", b/GB)
58 case b >= MB:
59 return fmt.Sprintf(format+"MB", b/MB)
60 case b >= KB:
61 return fmt.Sprintf(format+"KB", b/KB)
62 }
63 return fmt.Sprintf("%.0fB", b)
64}
65
66func main() {
67 fmt.Println(YB, ByteSize(1e13))

Callers 15

StringMethod · 0.95
columnCapacityDiskTotalFunction · 0.80
columnMemoryLimitFunction · 0.80
columnTotalMemoryUsedFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected