Documentation
¶
Index ¶
- func Atoi(b []byte) (int, error)
- func BytesToString(b []byte) string
- func Max(a, b int) int
- func Min(a, b int) int
- func MustParseFloat(s string) float64
- func ParseFloat(b []byte, bitSize int) (float64, error)
- func ParseInt(b []byte, base int, bitSize int) (int64, error)
- func ParseStringToFloat(s string) (float64, error)
- func ParseUint(b []byte, base int, bitSize int) (uint64, error)
- func SafeIntToInt32(value int, fieldName string) (int32, error)
- func StringToBytes(s string) []byte
- func ToPtr[T any](v T) *T
- type AtomicMax
- type AtomicMin
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BytesToString ¶
BytesToString converts byte slice to string.
func MustParseFloat ¶ added in v9.9.0
MustParseFloat is like ParseFloat but panics on parse errors.
func ParseStringToFloat ¶ added in v9.9.0
ParseFloat parses a Redis RESP3 float reply into a Go float64, handling "inf", "-inf", "nan" per Redis conventions.
func SafeIntToInt32 ¶ added in v9.15.0
SafeIntToInt32 safely converts an int to int32, returning an error if overflow would occur.
func StringToBytes ¶
StringToBytes converts string to byte slice.
Types ¶
type AtomicMax ¶
type AtomicMax struct {
// contains filtered or unexported fields
}
AtomicMax is a thread-safe max container
- hasValue indicator true if a value was equal to or greater than threshold
- optional threshold for minimum accepted max value
- if threshold is not used, initialization-free
- —
- wait-free CompareAndSwap mechanic
func NewAtomicMax ¶
func NewAtomicMax() (atomicMax *AtomicMax)
NewAtomicMax returns a thread-safe max container
- if threshold is not used, AtomicMax is initialization-free
func (*AtomicMax) Max ¶
Max returns current max and value-present flag
- hasValue true indicates that value reflects a Value invocation
- hasValue false: value is zero-value
- Thread-safe
func (*AtomicMax) Max1 ¶
Max1 returns current maximum whether zero-value or set by Value
- threshold is ignored
- Thread-safe
func (*AtomicMax) Value ¶
Value updates the container with a possible max value
- isNewMax is true if:
- — value is equal to or greater than any threshold and
- — invocation recorded the first 0 or
- — a new max
- upon return, Max and Max1 are guaranteed to reflect the invocation
- the return order of concurrent Value invocations is not guaranteed
- Thread-safe
type AtomicMin ¶
type AtomicMin struct {
// contains filtered or unexported fields
}
AtomicMin is a thread-safe Min container
- hasValue indicator true if a value was equal to or greater than threshold
- optional threshold for minimum accepted Min value
- —
- wait-free CompareAndSwap mechanic
func NewAtomicMin ¶
func NewAtomicMin() (atomicMin *AtomicMin)
NewAtomicMin returns a thread-safe Min container
- if threshold is not used, AtomicMin is initialization-free
func (*AtomicMin) Min ¶
Min returns current min and value-present flag
- hasValue true indicates that value reflects a Value invocation
- hasValue false: value is zero-value
- Thread-safe
func (*AtomicMin) Min1 ¶
Min1 returns current Minimum whether zero-value or set by Value
- threshold is ignored
- Thread-safe
func (*AtomicMin) Value ¶
Value updates the container with a possible Min value
- isNewMin is true if:
- — value is equal to or greater than any threshold and
- — invocation recorded the first 0 or
- — a new Min
- upon return, Min and Min1 are guaranteed to reflect the invocation
- the return order of concurrent Value invocations is not guaranteed
- Thread-safe