Documentation
¶
Index ¶
Constants ¶
const ( KiB ByteQuantity = 1024 MiB = 1024 * KiB GiB = 1024 * MiB TiB = 1024 * GiB PiB = 1024 * TiB EiB = 1024 * PiB )
Binary SI size constants.
const ( UnitKiB = "KiB" UnitMiB = "MiB" UnitGiB = "GiB" UnitTiB = "TiB" UnitPiB = "PiB" UnitEiB = "EiB" )
Unit suffix constants for use with FormatByteQuantity.
Variables ¶
This section is empty.
Functions ¶
func FormatByteQuantity ¶
func FormatByteQuantity(b ByteQuantity, unit string) string
FormatByteQuantity formats b in the given binary SI unit (use the UnitXiB constants). "" formats as plain bytes. Example: FormatByteQuantity(8*GiB, UnitGiB) → "8GiB".
func FormatMillicores ¶
func FormatMillicores(m Millicores, unit string) string
FormatMillicores formats m in the given decimal SI unit prefix. unit: "m" (millicores), "" (whole cores). Example: FormatMillicores(1000, "m") → "1000m", FormatMillicores(1000, "") → "1".
Types ¶
type ByteQuantity ¶
type ByteQuantity int64
ByteQuantity stores a memory quantity as int64 bytes (the smallest unit). Implements pflag.Value for use with cmd.Flags().Var().
func ParseByteQuantity ¶
func ParseByteQuantity(s string) (ByteQuantity, error)
ParseByteQuantity parses a byte quantity string. Accepts E/Ei/EiB, P/Pi/PiB, T/Ti/TiB, G/Gi/GiB, M/Mi/MiB, K/Ki/KiB, or bare integer (treated as GiB).
func (ByteQuantity) GiB ¶
func (b ByteQuantity) GiB() int64
GiB returns the quantity as an integer number of gibibytes (truncating).
func (ByteQuantity) String ¶
func (b ByteQuantity) String() string
String implements pflag.Value. Auto-picks the largest binary SI unit that divides evenly: 8*GiB → "8GiB". Returns "" for zero.
type Millicores ¶
type Millicores int64
Millicores stores a CPU/GPU quantity as int64 millicores (the smallest unit). Implements pflag.Value for use with cmd.Flags().Var().
func ParseMillicores ¶
func ParseMillicores(s string) (Millicores, error)
ParseMillicores parses a millicore string. "1" → 1000, "0.5" → 500, "1000m" → 1000.
func (Millicores) String ¶
func (m Millicores) String() string
String implements pflag.Value. Auto-picks the best decimal SI unit: 1000 → "1", 500 → "500m". Returns "" for zero.