Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ByteSizeFormatFloat = DefaultByteSizeFormatFloat
ByteSizeFormatFloat defines how floating-point values are formatted in String(). It can be replaced to customize output precision.
Functions ¶
func DefaultByteSizeFormatFloat ¶
DefaultByteSizeFormatFloat formats a float with up to 2 decimals, trimming trailing zeros and the decimal point if unnecessary.
Types ¶
type ByteSize ¶
type ByteSize int64
ByteSize represents a quantity of bytes.
func MustParseByteSize ¶ added in v0.1.81
MustParseByteSize parses a size string and panics if it is invalid.
func NewByteSize ¶
NewByteSize creates a ByteSize from a numeric value and a unit string. Example: NewByteSize(1.5, "GB") -> 1.5GB. Returns an error if the unit is not recognized.
func ParseByteSize ¶
ParseByteSize parses a human-readable size string (e.g. "1.5GB", "100 KB") and returns the corresponding ByteSize value.
func (ByteSize) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (ByteSize) String ¶
String returns a human-readable representation of the byte size. e.g. 1536 -> "1.5KB", 1048576 -> "1MB".
func (ByteSize) To ¶ added in v0.1.81
To converts the ByteSize to the specified unit and returns its string representation.
func (*ByteSize) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.