Documentation
¶
Index ¶
- func Abs[T constraints.Integer](n T) T
- func AllZero[T Integer](v ...T) bool
- func AppendLineToFile(filename string, format string, args ...any)
- func AppendUnique[T comparable](slice []T, elems ...T) []T
- func AssertMustError(err error, target ...error)
- func AssertNoError(err error, prefix ...string)
- 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 ED25519PrivateKeyFromHexString(str string) (ed25519.PrivateKey, error)
- func EqualSlices[T comparable](s1, s2 []T) bool
- func ErrorCondf(cond bool, format string, args ...any) error
- 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 MustClose(f io.Closer)
- func MustErrorWith(err error, fragments ...string) error
- 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 RequireErrorWithOld(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 ThLazy[T Integer](v T, separator ...string) func() string
- func ThSlice[T Integer](v ...T) 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 AppendLineToFile ¶
func AppendUnique ¶
func AppendUnique[T comparable](slice []T, elems ...T) []T
func AssertMustError ¶
func AssertNoError ¶
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 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 MustErrorWith ¶
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 sema implements semaphore with timeout
|
Package sema implements semaphore with timeout |
|
Package trackgc contains tools to track garbage collection
|
Package trackgc contains tools to track garbage collection |