Documentation
¶
Overview ¶
Package ht provides parsing and printing utilities for human-readable types.
Index ¶
- Constants
- type ByteSizeIEC
- func (b ByteSizeIEC) AppendText(data []byte) ([]byte, error)
- func (b ByteSizeIEC) MarshalJSON() ([]byte, error)
- func (b ByteSizeIEC) MarshalText() ([]byte, error)
- func (b ByteSizeIEC) String() string
- func (b *ByteSizeIEC) UnmarshalJSON(data []byte) error
- func (b *ByteSizeIEC) UnmarshalText(data []byte) error
- type ByteSizeSI
- func (b ByteSizeSI) AppendText(data []byte) ([]byte, error)
- func (b ByteSizeSI) MarshalJSON() ([]byte, error)
- func (b ByteSizeSI) MarshalText() ([]byte, error)
- func (b ByteSizeSI) String() string
- func (b *ByteSizeSI) UnmarshalJSON(data []byte) error
- func (b *ByteSizeSI) UnmarshalText(data []byte) error
- type Clock
- func (c Clock) After(u Clock) bool
- func (c Clock) AppendBinary(b []byte) ([]byte, error)
- func (c Clock) AppendText(b []byte) ([]byte, error)
- func (c Clock) Before(u Clock) bool
- func (c Clock) Clock() (hour, minute, second int)
- func (c Clock) Compare(u Clock) int
- func (c Clock) Hour() int
- func (c Clock) IsZero() bool
- func (c Clock) MarshalBinary() ([]byte, error)
- func (c Clock) MarshalJSON() ([]byte, error)
- func (c Clock) MarshalText() ([]byte, error)
- func (c Clock) Minute() int
- func (c Clock) Second() int
- func (c Clock) String() string
- func (c Clock) Time() time.Time
- func (c *Clock) UnmarshalBinary(b []byte) error
- func (c *Clock) UnmarshalJSON(b []byte) error
- func (c *Clock) UnmarshalText(b []byte) error
- type Date
- func (d Date) Add(years, months, days int) Date
- func (d Date) After(u Date) bool
- func (d Date) AppendBinary(b []byte) ([]byte, error)
- func (d Date) AppendText(b []byte) ([]byte, error)
- func (d Date) Before(u Date) bool
- func (d Date) Compare(u Date) int
- func (d Date) Date() (year int, month time.Month, day int)
- func (d Date) Day() int
- func (d Date) IsZero() bool
- func (d Date) MarshalBinary() ([]byte, error)
- func (d Date) MarshalJSON() ([]byte, error)
- func (d Date) MarshalText() ([]byte, error)
- func (d Date) Month() time.Month
- func (d Date) String() string
- func (d Date) Time() time.Time
- func (d *Date) UnmarshalBinary(b []byte) error
- func (d *Date) UnmarshalJSON(b []byte) error
- func (d *Date) UnmarshalText(b []byte) error
- func (d Date) Weekday() time.Weekday
- func (d Date) Year() int
- type Duration
- type TimeRate
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) AppendText ¶ added in v0.3.0
func (b ByteSizeIEC) AppendText(data []byte) ([]byte, error)
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) AppendText ¶ added in v0.3.0
func (b ByteSizeSI) AppendText(data []byte) ([]byte, error)
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) MarshalBinary ¶ added in v0.4.0
func (Clock) MarshalJSON ¶
func (Clock) MarshalText ¶
func (*Clock) UnmarshalBinary ¶ added in v0.4.0
func (*Clock) UnmarshalJSON ¶
func (*Clock) UnmarshalText ¶
type Date ¶ added in v0.3.0
type Date struct {
// contains filtered or unexported fields
}
func (Date) MarshalBinary ¶ added in v0.4.0
func (Date) MarshalJSON ¶ added in v0.3.0
func (Date) MarshalText ¶ added in v0.3.0
func (*Date) UnmarshalBinary ¶ added in v0.4.0
func (*Date) UnmarshalJSON ¶ added in v0.3.0
func (*Date) UnmarshalText ¶ added in v0.3.0
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.0
TimeRate represents a quantity per time period.
func ParseTimeRate ¶ added in v0.2.0
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".