Documentation ¶
Index ¶
- Constants
- Variables
- func Abs[T constraints.Signed](n T) T
- func Basename(s string) string
- func Clamp[T constraints.Ordered](val, minIn, maxIn T) T
- func ClampTime(val, min, max time.Time) time.Time
- func ContainsString(s string, list []string) bool
- func DaysBetween(a, b time.Time) int
- func DaysIn(m time.Month, year int) int
- func EscapeWhitespace(s string) string
- func FirstNonZeroTime(val time.Time, others ...time.Time) time.Time
- func Fqdn() string
- func FromCamelCase(src, sep string) string
- func HashString(s string) string
- func HexString(v interface{}) string
- func Int16AsUint16Slice(src []int16) []uint16
- func Int32AsUint32Slice(src []int32) []uint32
- func Int64AsUint64Slice(src []int64) []uint64
- func Int8AsUint8Slice(src []int8) []uint8
- func IsASCII(s string) bool
- func IsBase64(s string) bool
- func JoinString(sep string, more ...string) string
- func JsonString(v interface{}) string
- func LimitString(s string, l int) string
- func LimitStringEllipsis(s string, l int) string
- func LogCPUFeatures(l *log.Logger)
- func MaxBytes(a, b []byte) []byte
- func MaxDuration(a, b time.Duration) time.Duration
- func MaxTime(x, y time.Time) time.Time
- func MaxTimeN(t ...time.Time) time.Time
- func MinBytes(a, b []byte) []byte
- func MinDuration(a, b time.Duration) time.Duration
- func MinMax[T constraints.Ordered](vals ...T) (T, T)
- func MinMaxTime(s []time.Time) (time.Time, time.Time)
- func MinTime(x, y time.Time) time.Time
- func MinTimeN(t ...time.Time) time.Time
- func NonEmptyString(s ...string) string
- func NonZero[T constraints.Ordered](x ...T) T
- func NonZeroMin[T constraints.Ordered](x ...T) T
- func NonZeroSince(start time.Time) time.Duration
- func Pow[T constraints.Integer](a, b T) (c T)
- func Pretty(val interface{}) string
- func PrettyFloat64(f float64) string
- func PrettyFloat64N(f float64, decimals int) string
- func PrettyInt(i int) string
- func PrettyInt64(i int64) string
- func PrettyString(s string) string
- func PrettyUint64(i uint64) string
- func QuoteString(s string) string
- func RoundToDays(d time.Duration) int
- func RoundToHours(d time.Duration) int64
- func RoundToMillisecond(d time.Duration) int64
- func RoundToMinutes(d time.Duration) int64
- func RoundToSeconds(d time.Duration) int64
- func StepsBetween(t1, t2 time.Time, d time.Duration) []time.Time
- func ToCamelCase(src, sep string) string
- func ToRawString(t interface{}) (string, error)
- func ToString(t interface{}) string
- func TrimAllSpace(str string) string
- func TruncateDuration(d, r time.Duration) time.Duration
- func Uint16AsInt16Slice(src []uint16) []int16
- func Uint32AsInt32Slice(src []uint32) []int32
- func Uint64AsInt64Slice(src []uint64) []int64
- func Uint8AsInt8Slice(src []uint8) []int8
- func UnescapeWhitespace(s string) string
- func UniqueStrings(s []string) []string
- func UnixMicro(t time.Time) int64
- func UnixMicroNonZero(t time.Time) int64
- func UnixMilli(t time.Time) int64
- func UnixMilliNonZero(t time.Time) int64
- func UnixNano(t time.Time) int64
- func UnixNanoNonZero(t time.Time) int64
- func UnixNonZero(t time.Time) int64
- func UnsafeGetBytes(s string) []byte
- func UnsafeGetString(b []byte) string
- type AlignedTicker
- type BitRate
- type ByteSize
- type Duration
- func (d Duration) Duration() time.Duration
- func (d Duration) MarshalText() ([]byte, error)
- func (d Duration) RoundToDays() int
- func (d Duration) RoundToHours() int64
- func (d Duration) RoundToMillisecond() int64
- func (d Duration) RoundToMinutes() int64
- func (d Duration) RoundToSeconds() int64
- func (d Duration) String() string
- func (d Duration) Truncate(r time.Duration) Duration
- func (d *Duration) UnmarshalJSON(data []byte) error
- func (d *Duration) UnmarshalText(data []byte) error
- type GenericPool
- type SizedPool
- type StringList
- func (l *StringList) Add(r string) StringList
- func (l *StringList) AddFront(r string) StringList
- func (l *StringList) AddUnique(r string) StringList
- func (l *StringList) AddUniqueFront(r string) StringList
- func (l StringList) AsInterface() []interface{}
- func (l StringList) Contains(r string) bool
- func (l StringList) Index(r string) int
- func (l StringList) MarshalText() ([]byte, error)
- func (l StringList) String() string
- func (l *StringList) UnmarshalText(data []byte) error
- type Time
- func (t Time) Add(d time.Duration) Time
- func (t Time) AddDate(years int, months int, days int) Time
- func (t Time) After(a Time) bool
- func (t Time) AppendFormat(b []byte, layout string) []byte
- func (t Time) Before(a Time) bool
- func (t Time) Date() (int, time.Month, int)
- func (t Time) DaysSince(a Time) int
- func (f Time) EOD() Time
- func (f Time) EODTime() time.Time
- func (t Time) Equal(t2 Time) bool
- func (t Time) Format(layout string) string
- func (f Time) GetFormat() TimeFormat
- func (f Time) IsDate() bool
- func (t Time) IsZero() bool
- func (f Time) MarshalJSON() ([]byte, error)
- func (f Time) MarshalText() ([]byte, error)
- func (t *Time) SetFormat(f TimeFormat) *Time
- func (f Time) String() string
- func (f Time) Time() time.Time
- func (t Time) Truncate(d time.Duration) Time
- func (t Time) Unix() int64
- func (t Time) UnixMicro() int64
- func (t Time) UnixMilli() int64
- func (t Time) UnixNano() int64
- func (f *Time) UnmarshalJSON(data []byte) error
- func (f *Time) UnmarshalText(data []byte) error
- func (t Time) Year() int
- type TimeFormat
- type TimeUnit
- func (c TimeUnit) Add(t time.Time) time.Time
- func (c TimeUnit) Base() time.Duration
- func (c TimeUnit) Between(from, to time.Time, limit int) []time.Time
- func (c TimeUnit) Duration() time.Duration
- func (c TimeUnit) MarshalText() ([]byte, error)
- func (c TimeUnit) Next(t time.Time, n int) time.Time
- func (c TimeUnit) Steps(from, to time.Time, limit int) []time.Time
- func (c TimeUnit) String() string
- func (c TimeUnit) Sub(t time.Time) time.Time
- func (c TimeUnit) Truncate(t time.Time) time.Time
- func (c *TimeUnit) UnmarshalText(data []byte) error
- type U64String
- type WallTicker
Constants ¶
Variables ¶
var ( IsAMD64 bool // is this an x86 AMD64 CPU UseAVX2 bool // AVX-2 available UseAVX512_F bool // AVX-512 Foundation Instructions UseAVX512_DQ bool // AVX-512 Doubleword & Quadword Instrs UseAVX512_IFMA bool // AVX-512 Integer Fused Multiply Add UseAVX512_PF bool // AVX-512 Prefetch Instructions UseAVX512_ER bool // AVX-512 Exponent & Reciprocal Instrs UseAVX512_CD bool // AVX-512 Conflict Detection Instrs UseAVX512_BW bool // AVX-512 Byte and Word Instructions UseAVX512_VL bool // AVX-512 Vector Length Extensions UseAVX512_VBMI bool // AVX-512 Vector Byte Manipulation Instrs UseAVX512_BITALG bool // Support for VPOPCNT[B,W] and VPSHUFBITQMB UseAVX512_VPOPCNTDQ bool // POPCNT for vectors of DW/QW UseAVX512_4VNNIW bool // AVX512 Neural Network Instructions UseAVX512_4FMAPS bool // AVX512 Multiply Accumulation Single Precision UseAVX512_VP2INTERSECT bool // VP2INTERSECT{D,Q} insns UseAVX512_BF16 bool // AVX512 BFloat16 Instructions )
var ( EnableAVX = noop DisableAVX2 = noop DisableAVX512 = noop )
var EInvalidBitrate = errors.New("invalid bitrate")
var EInvalidByteSize = errors.New("invalid byte size")
var FormatMap = map[TimeFormat]string{ TimeFormatDefault: time.RFC3339, TimeFormatUnix: "", TimeFormatUnixMicro: "", TimeFormatUnixMilli: "", TimeFormatUnixNano: "", TimeFormatDate: "2006-01-02", }
var TimeFormats []string = []string{ time.RFC3339, "02.01.2006T15:04:05.999999999Z07:00", "02.01.2006T15:04:05Z07:00", "02.01.2006 15:04:05.999999999Z07:00", "02.01.2006 15:04:05Z07:00", "2006:01:02 15:04:05.999999999-07:00", "2006:01:02 15:04:05-07:00", "2006:01:02:15:04:05-07:00", "2006:01:02:15:04:05-07", "2006-01-02T15:04:05.999999999Z", "2006-01-02T15:04:05Z", "2006-01-02 15:04:05.999999999Z", "2006-01-02 15:04:05Z", "02.01.2006T15:04:05.999999999Z", "02.01.2006T15:04:05Z", "02.01.2006 15:04:05.999999999Z", "02.01.2006 15:04:05Z", "2006-01-02T15:04:05.999999999", "2006-01-02T15:04:05", "2006-01-02 15:04:05.999999999", "2006-01-02 15:04:05", "02.01.2006T15:04:05.999999999", "02.01.2006T15:04:05", "02.01.2006 15:04:05.999999999", "02.01.2006 15:04:05", "2006-01-02T15:04", "2006-01-02 15:04", "02.01.2006T15:04", "02.01.2006 15:04", "2006-01-02", "02.01.2006", "2006-01", "01.2006", "15:04:05", "15:04", "2006", }
Functions ¶
func Abs ¶
func Abs[T constraints.Signed](n T) T
func Clamp ¶
func Clamp[T constraints.Ordered](val, minIn, maxIn T) T
func ContainsString ¶
func DaysBetween ¶
func EscapeWhitespace ¶
func FromCamelCase ¶
func HashString ¶
func Int16AsUint16Slice ¶
func Int32AsUint32Slice ¶
func Int64AsUint64Slice ¶
func Int8AsUint8Slice ¶
func JoinString ¶
func JsonString ¶
func JsonString(v interface{}) string
func LimitString ¶
limits the length of string to l UTF8 runes
func LimitStringEllipsis ¶
func LogCPUFeatures ¶
func MinMax ¶
func MinMax[T constraints.Ordered](vals ...T) (T, T)
func NonEmptyString ¶
func NonZero ¶
func NonZero[T constraints.Ordered](x ...T) T
func NonZeroMin ¶
func NonZeroMin[T constraints.Ordered](x ...T) T
func Pow ¶ added in v0.2.8
func Pow[T constraints.Integer](a, b T) (c T)
Donald Knuth, The Art of Computer Programming, Volume 2, Section 4.6.3
func PrettyFloat64 ¶
func PrettyFloat64N ¶
func PrettyInt64 ¶
func PrettyString ¶
not pretty, but works: 1000000.123 -> 1,000,000.123
func PrettyUint64 ¶
func QuoteString ¶
func RoundToDays ¶
func RoundToHours ¶
func RoundToMillisecond ¶
func RoundToMinutes ¶
func RoundToSeconds ¶
func ToCamelCase ¶
func ToRawString ¶
func TrimAllSpace ¶
func Uint16AsInt16Slice ¶
func Uint32AsInt32Slice ¶
func Uint64AsInt64Slice ¶
func Uint8AsInt8Slice ¶
func UnescapeWhitespace ¶
func UniqueStrings ¶
func UnixMicroNonZero ¶
func UnixMilliNonZero ¶
func UnixNanoNonZero ¶
func UnixNonZero ¶
func UnsafeGetString ¶
Types ¶
type AlignedTicker ¶
type AlignedTicker struct { sync.Mutex sync.Once C <-chan time.Time // contains filtered or unexported fields }
func NewAlignedTicker ¶
func NewAlignedTicker(d time.Duration) *AlignedTicker
func (*AlignedTicker) Stop ¶
func (t *AlignedTicker) Stop()
type BitRate ¶
type BitRate float64
func ParseBitRate ¶
func (BitRate) MarshalText ¶
func (*BitRate) UnmarshalText ¶
type ByteSize ¶
type ByteSize float64
func ParseByteSize ¶
func (ByteSize) MarshalText ¶
func (*ByteSize) UnmarshalText ¶
type Duration ¶
func ParseDuration ¶
func (Duration) MarshalText ¶
func (Duration) RoundToDays ¶
func (Duration) RoundToHours ¶
func (Duration) RoundToMillisecond ¶
func (Duration) RoundToMinutes ¶
func (Duration) RoundToSeconds ¶
func (*Duration) UnmarshalJSON ¶
func (*Duration) UnmarshalText ¶
type GenericPool ¶
type GenericPool struct {
// contains filtered or unexported fields
}
GenericPool is a pool of types that can be re-used. Items in this pool will not be garbage collected when not in use.
func NewGenericPool ¶
func NewGenericPool(max int, fn func() interface{}) *GenericPool
NewGeneric returns a Generic pool with capacity for max items to be pool.
func (*GenericPool) Get ¶
func (p *GenericPool) Get() interface{}
Get returns a item from the pool or a new instance if the pool is empty. Items returned may not be in the zero state and should be reset by the caller.
func (*GenericPool) Put ¶
func (p *GenericPool) Put(c interface{})
Put returns an item back to the pool. If the pool is full, the item is discarded.
type SizedPool ¶
type SizedPool struct {
// contains filtered or unexported fields
}
Sized is a pool of types that can be re-used. Items in this pool will not be garbage collected when not in use.
func NewSizedPool ¶
NewSized returns a Sized pool with capacity for max items to be pool.
type StringList ¶
type StringList []string
func (*StringList) Add ¶
func (l *StringList) Add(r string) StringList
func (*StringList) AddFront ¶
func (l *StringList) AddFront(r string) StringList
func (*StringList) AddUnique ¶
func (l *StringList) AddUnique(r string) StringList
func (*StringList) AddUniqueFront ¶
func (l *StringList) AddUniqueFront(r string) StringList
func (StringList) AsInterface ¶
func (l StringList) AsInterface() []interface{}
func (StringList) Contains ¶
func (l StringList) Contains(r string) bool
func (StringList) Index ¶
func (l StringList) Index(r string) int
func (StringList) MarshalText ¶
func (l StringList) MarshalText() ([]byte, error)
func (StringList) String ¶
func (l StringList) String() string
func (*StringList) UnmarshalText ¶
func (l *StringList) UnmarshalText(data []byte) error
type Time ¶
type Time struct {
// contains filtered or unexported fields
}
func (Time) GetFormat ¶
func (f Time) GetFormat() TimeFormat
func (Time) MarshalJSON ¶
func (Time) MarshalText ¶
func (*Time) SetFormat ¶
func (t *Time) SetFormat(f TimeFormat) *Time
func (*Time) UnmarshalJSON ¶
func (*Time) UnmarshalText ¶
type TimeFormat ¶
type TimeFormat int
const ( TimeFormatDefault TimeFormat = iota TimeFormatUnix TimeFormatUnixMicro TimeFormatUnixMilli TimeFormatUnixNano TimeFormatDate )
func (TimeFormat) IsUnix ¶
func (f TimeFormat) IsUnix() bool
type TimeUnit ¶
func ParseTimeUnit ¶
func (TimeUnit) MarshalText ¶
func (TimeUnit) Truncate ¶
Truncate truncates t to time unit ignoring its value, e.g. - minutes: full minute - hours: full hour - days: midnight UTC - weeks: midnight UTC on first day of week (Sunday) - months: midnight UTC on first day of month - quarters: midnight UTC on first day of quarter - years: midnight UTC on first day of year
func (*TimeUnit) UnmarshalText ¶
type U64String ¶
type U64String uint64
func DecodeU64String ¶
func (U64String) MarshalText ¶
func (*U64String) UnmarshalText ¶
type WallTicker ¶
type WallTicker struct { sync.Mutex sync.Once C <-chan time.Time // contains filtered or unexported fields }
More accurate Ticker from https://github.com/golang/go/issues/19810
func NewWallTicker ¶
func NewWallTicker(align, offset time.Duration) *WallTicker
func (*WallTicker) Stop ¶
func (w *WallTicker) Stop()