Documentation ¶
Index ¶
- func Abs[T constraints.Integer](n T) T
- func AppendUnique[T comparable](slice []T, elems ...T) []T
- func AssertMustError(err error, target ...error)
- func AssertNoError(err error, prefix ...string)
- func AssertNotNil[T comparable](el T)
- func Assertf(cond bool, format string, args ...any)
- func CallWithTimeout(ctx context.Context, timeout time.Duration, fun, onTimeout func())
- func CatchPanicOrError(f func() error, includeStack ...bool) error
- func Cond[T any](cond bool, ifTrue, ifFalse T) T
- func DoUntil(bodyFun func(), cond func() bool)
- func ED25519PrivateKeyFromHexString(str string) (ed25519.PrivateKey, error)
- func EqualSlices[T comparable](s1, s2 []T) bool
- func ErrorConditionf(cond bool, format string, args ...any) error
- func EvalLazyArgs(args ...any) []any
- func ForEachUniquePair[T any](sl []T, fun func(a1, a2 T) bool)
- func IndexOfMaximum[T any](lst []T, less func(i1, i2 int) bool) int
- func IsNil(p interface{}) bool
- func KeysFiltered[K comparable, V any](m map[K]V, cond func(k K) bool) []K
- func KeysFilteredByValues[K comparable, V any](m map[K]V, cond func(k K, v V) bool) []K
- func KeysSorted[K comparable, V any](m map[K]V, less func(k1, k2 K) bool) []K
- func List[T any](elems ...T) []T
- func MakeErrFuncForPrefix(prefix string) func(err interface{}, args ...interface{}) error
- func MakeRange[T constraints.Integer](from, toIncl T) []T
- func Maximum[T any](lst []T, less func(el1, el2 T) bool) T
- func Median[T Number](data []T) T
- func MustLastElement[T any](sl []T) T
- func MustPrivateKeyFromHexString(k string) ed25519.PrivateKey
- func Panicf(format string, args ...any)
- func Percent(n, d int) float32
- func PercentString(n, d int) string
- func PrivateKeyFromHexString(k string) (ed25519.PrivateKey, error)
- func PurgeFilesInDirectory(directory, namePattern string, keepLatest int) error
- func PurgeSlice[T any](slice []T, filter func(el T) bool) []T
- func Quartiles[T Number](data []T) (ret [3]T)
- func RandomElements[T any](n int, elems ...T) []T
- func RandomNOutOfMPractical(n, m int) []int
- func Ref[T any](v T) *T
- func RequireErrorWith(t *testing.T, err error, fragments ...string)
- func RequirePanicOrErrorWith(t *testing.T, f func() error, fragments ...string)
- func RunWrappedRoutine(name string, fun func(), onPanic func(err error) bool)
- func StringsLess(s1, s2 string) bool
- func Th[T Integer](v T, separator ...string) string
- func TrimSlice[T any](slice []T, maxLen int) []T
- func ValuesFiltered[K comparable, V any](m map[K]V, filter func(v V) bool) []V
- type Integer
- type Number
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Abs ¶
func Abs[T constraints.Integer](n T) T
func AppendUnique ¶
func AppendUnique[T comparable](slice []T, elems ...T) []T
func AssertMustError ¶
func AssertNoError ¶
func AssertNotNil ¶
func AssertNotNil[T comparable](el T)
func CallWithTimeout ¶
CallWithTimeout calls fun. If it does not finish in timeout period, calls onTimeout
func CatchPanicOrError ¶
func ED25519PrivateKeyFromHexString ¶
func ED25519PrivateKeyFromHexString(str string) (ed25519.PrivateKey, error)
func EqualSlices ¶
func EqualSlices[T comparable](s1, s2 []T) bool
func EvalLazyArgs ¶
func ForEachUniquePair ¶
func IndexOfMaximum ¶
IndexOfMaximum slice cannot be empty
func KeysFiltered ¶
func KeysFiltered[K comparable, V any](m map[K]V, cond func(k K) bool) []K
func KeysFilteredByValues ¶
func KeysFilteredByValues[K comparable, V any](m map[K]V, cond func(k K, v V) bool) []K
func KeysSorted ¶
func KeysSorted[K comparable, V any](m map[K]V, less func(k1, k2 K) bool) []K
func MakeErrFuncForPrefix ¶
func MakeRange ¶
func MakeRange[T constraints.Integer](from, toIncl T) []T
func MustLastElement ¶
func MustLastElement[T any](sl []T) T
func MustPrivateKeyFromHexString ¶
func MustPrivateKeyFromHexString(k string) ed25519.PrivateKey
func PercentString ¶
func PrivateKeyFromHexString ¶
func PrivateKeyFromHexString(k string) (ed25519.PrivateKey, error)
func PurgeFilesInDirectory ¶
func PurgeSlice ¶
PurgeSlice filters elements on the same underlying array Element remains in the array only if 'filter' function returns true The elements of the array which are not covered by slice are nullified. This may be important when slice contains pointers, which, in turn, may lead to hidden memory leak because GC can't remove them
func RandomElements ¶
RandomElements selects n random elements from a slice, which has more elements than n
func RandomNOutOfMPractical ¶
RandomNOutOfMPractical tries to generate n different random numbers from [0:m]. Only makes 2 * n attempts, so result may be less than n numbers
func RequirePanicOrErrorWith ¶
func RunWrappedRoutine ¶
func StringsLess ¶
func ValuesFiltered ¶
func ValuesFiltered[K comparable, V any](m map[K]V, filter func(v V) bool) []V
Types ¶
type Number ¶
type Number interface { constraints.Float | constraints.Integer | time.Duration }
Directories ¶
Path | Synopsis |
---|---|
Package lazybytes is a way to treat byte data as serialized arrays or, recursively, as trees of byte slices It is used for fast, safe and uniform serialization/deserialization in 'lazy' way: the bytes are only deserialized when there's a need to access element of the array or a tree The read-only lazy array and tree are thread safe.
|
Package lazybytes is a way to treat byte data as serialized arrays or, recursively, as trees of byte slices It is used for fast, safe and uniform serialization/deserialization in 'lazy' way: the bytes are only deserialized when there's a need to access element of the array or a tree The read-only lazy array and tree are thread safe. |
Package sema implements semaphore with timeout
|
Package sema implements semaphore with timeout |