Documentation
¶
Overview ¶
Package ht provides parsing and printing utilities for human-readable types.
Index ¶
Constants ¶
const ( KB ByteSizeSI = 1000 MB = KB * 1000 GB = MB * 1000 TB = GB * 1000 PB = TB * 1000 EB = PB * 1000 )
const ( KiB ByteSizeIEC = 1024 MiB = KiB * 1024 GiB = MiB * 1024 TiB = GiB * 1024 PiB = TiB * 1024 EiB = PiB * 1024 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ByteSizeIEC ¶
type ByteSizeIEC uint64
ByteSizeIEC is a byte size in IEC units.
func ParseByteSizeIEC ¶
func ParseByteSizeIEC(s string) (ByteSizeIEC, error)
ParseByteSizeIEC parses a byte size string. A byte size string is a decimal number with an optional fraction and unit suffix, such as "1k", "1.5M" or "2MB".
Valid IEC units are: - k, K, KiB - kibibyte - M, MiB - mebibyte - G, GiB - gibibyte - T, TiB - tebibyte - P, PiB - pebibyte - E, EiB - exbibyte
Valid SI units are: - kB, KB - kilobyte - MB - megabyte - GB - gigabyte - TB - terabyte - PB - petabyte - EB - exabyte
NOTE: Accepts both IEC and SI units.
func (ByteSizeIEC) MarshalJSON ¶
func (b ByteSizeIEC) MarshalJSON() ([]byte, error)
func (ByteSizeIEC) MarshalText ¶
func (b ByteSizeIEC) MarshalText() ([]byte, error)
func (ByteSizeIEC) String ¶
func (b ByteSizeIEC) String() string
func (*ByteSizeIEC) UnmarshalJSON ¶
func (b *ByteSizeIEC) UnmarshalJSON(data []byte) error
func (*ByteSizeIEC) UnmarshalText ¶
func (b *ByteSizeIEC) UnmarshalText(data []byte) error
type ByteSizeSI ¶
type ByteSizeSI uint64
ByteSizeSI is a byte size in SI units.
func ParseByteSizeSI ¶
func ParseByteSizeSI(s string) (ByteSizeSI, error)
ParseByteSizeSI parses a byte size string. A byte size string is a decimal number with an optional fraction and unit suffix, such as "1k", "1.5M" or "2MB".
Valid IEC units are: - k, K, KiB - kibibyte - M, MiB - mebibyte - G, GiB - gibibyte - T, TiB - tebibyte - P, PiB - pebibyte - E, EiB - exbibyte
Valid SI units are: - kB, KB - kilobyte - MB - megabyte - GB - gigabyte - TB - terabyte - PB - petabyte - EB - exabyte
NOTE: Accepts both IEC and SI units.
func (ByteSizeSI) MarshalJSON ¶
func (b ByteSizeSI) MarshalJSON() ([]byte, error)
func (ByteSizeSI) MarshalText ¶
func (b ByteSizeSI) MarshalText() ([]byte, error)
func (ByteSizeSI) String ¶
func (b ByteSizeSI) String() string
func (*ByteSizeSI) UnmarshalJSON ¶
func (b *ByteSizeSI) UnmarshalJSON(data []byte) error
func (*ByteSizeSI) UnmarshalText ¶
func (b *ByteSizeSI) UnmarshalText(data []byte) error
type Clock ¶
type Clock struct {
// contains filtered or unexported fields
}
func ParseClock ¶
func (Clock) MarshalJSON ¶
func (Clock) MarshalText ¶
func (*Clock) UnmarshalJSON ¶
func (*Clock) UnmarshalText ¶
type Duration ¶
Duration is time.Duration with additional day unit (`d`) during parsing and with JSON and Text (un)marshaling support.
func ParseDuration ¶
ParseDuration parses a duration string. A duration string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as "300ms", "-1.5h" or "2h45m". Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h", "d".
func (Duration) MarshalJSON ¶
func (Duration) MarshalText ¶
func (*Duration) UnmarshalJSON ¶
func (*Duration) UnmarshalText ¶
type TimeRate ¶ added in v0.2.1
TimeRate represents a quantity per time period.
func ParseTimeRate ¶ added in v0.2.1
ParseTimeRate parses a time rate string in the format "units/duration", such as "100/s", "42/1s", "1000/5m", "50/500ms", "10/.2s" or "100/1s200ms".