MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / FormatBytesFloat

Function FormatBytesFloat

internal/ui/utils/formatting.go:65–79  ·  view source on GitHub ↗

FormatBytesFloat converts float64 GB values to human-readable format Input is assumed to be in GB, converts to appropriate units with 2 decimal places.

(gb float64)

Source from the content-addressed store, hash-verified

63// FormatBytesFloat converts float64 GB values to human-readable format
64// Input is assumed to be in GB, converts to appropriate units with 2 decimal places.
65func FormatBytesFloat(gb float64) string {
66 const (
67 TbInGb = 1024
68 PbInGb = 1024 * 1024
69 )
70
71 switch {
72 case gb >= PbInGb:
73 return fmt.Sprintf("%.2f PB", gb/PbInGb)
74 case gb >= TbInGb:
75 return fmt.Sprintf("%.2f TB", gb/TbInGb)
76 default:
77 return fmt.Sprintf("%.2f GB", gb)
78 }
79}
80
81// FormatStatusIndicator returns a string with a colored status indicator.
82// Uses theme-aware color tags.

Callers 1

UpdateMethod · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected