Documentation ¶
Index ¶
- Variables
- func BoolToInt(b bool) int
- func BoolToUint64(b bool) uint64
- func BytesToUint64(b []byte) (uint64, error)
- func DeepClone[T Codec](src T, factory func() T) T
- func Float64Equal(a, b float64) bool
- func JSONToUint64Slice(from interface{}) ([]uint64, bool)
- func MaxUint64(a, b uint64) uint64
- func MinDuration(a, b time.Duration) time.Duration
- func MinUint64(a, b uint64) uint64
- func ParseMBFromText(text string, value uint64) uint64
- func ParseTimestamp(data []byte) (time.Time, error)
- func StringsEqual(a, b []string) bool
- func SubRealTimeByWallClock(after, before time.Time) time.Duration
- func SubTSOPhysicalByWallClock(after, before time.Time) int64
- func Uint64ToBytes(v uint64) []byte
- type ByteSize
- type Codec
- type Duration
- type StringSlice
Constants ¶
This section is empty.
Variables ¶
var ZeroTime = time.Time{}
ZeroTime is a zero time.
Functions ¶
func BytesToUint64 ¶
BytesToUint64 converts a byte slice to uint64.
func DeepClone ¶
func DeepClone[T Codec](src T, factory func() T) T
DeepClone returns the deep copy of the source
func Float64Equal ¶
Float64Equal checks if two float64 are equal.
func JSONToUint64Slice ¶
JSONToUint64Slice converts JSON slice to uint64 slice.
func MinDuration ¶
MinDuration returns the min value between two variables whose type are time.Duration.
func ParseMBFromText ¶
ParseMBFromText parses MB from text.
func ParseTimestamp ¶
ParseTimestamp returns a timestamp for a given byte slice.
func StringsEqual ¶
StringsEqual checks if two string slices are equal. Empyt slice and nil are considered equal.
func SubRealTimeByWallClock ¶
SubRealTimeByWallClock returns the duration between two different time.Time structs. You should use it to compare the real-world system time. And DO NOT USE IT TO COMPARE two TSOs' physical times directly in some cases.
func SubTSOPhysicalByWallClock ¶
SubTSOPhysicalByWallClock returns the duration between two different TSOs' physical times with millisecond precision.
func Uint64ToBytes ¶
Uint64ToBytes converts uint64 to a byte slice.
Types ¶
type ByteSize ¶
type ByteSize uint64
ByteSize is a retype uint64 for TOML and JSON.
func (ByteSize) MarshalJSON ¶
MarshalJSON returns the size as a JSON string.
func (*ByteSize) UnmarshalJSON ¶
UnmarshalJSON parses a JSON string into the byte size.
func (*ByteSize) UnmarshalText ¶
UnmarshalText parses a Toml string into the byte size.
type Duration ¶
Duration is a wrapper of time.Duration for TOML and JSON.
func NewDuration ¶
NewDuration creates a Duration from time.Duration.
func (*Duration) MarshalJSON ¶
MarshalJSON returns the duration as a JSON string.
func (Duration) MarshalText ¶
MarshalText returns the duration as a JSON string.
func (*Duration) UnmarshalJSON ¶
UnmarshalJSON parses a JSON string into the duration.
func (*Duration) UnmarshalText ¶
UnmarshalText parses a TOML string into the duration.
type StringSlice ¶
type StringSlice []string
StringSlice is more friendly to json encode/decode
func (StringSlice) MarshalJSON ¶
func (s StringSlice) MarshalJSON() ([]byte, error)
MarshalJSON returns the size as a JSON string.
func (*StringSlice) UnmarshalJSON ¶
func (s *StringSlice) UnmarshalJSON(text []byte) error
UnmarshalJSON parses a JSON string into the byte size.