util

package
v0.0.0-...-261ff67 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 2, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

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 AssertMustError(err error, target ...error)

func AssertNoError

func AssertNoError(err error, prefix ...string)

func AssertNotNil

func AssertNotNil[T comparable](el T)

func Assertf

func Assertf(cond bool, format string, args ...any)

Assertf with optionally deferred evaluation of arguments

func CallWithTimeout

func CallWithTimeout(fun func(), timeout time.Duration) bool

func CatchPanicOrError

func CatchPanicOrError(f func() error, includeStack ...bool) error

func ClearSlice

func ClearSlice[T any](slice []T) []T

func CloneExactCap

func CloneExactCap(data []byte) []byte

func DoUntil

func DoUntil(bodyFun func(), cond func() bool)

func ED25519PrivateKeyFromHexString

func ED25519PrivateKeyFromHexString(str string) (ed25519.PrivateKey, error)

func EqualSlices

func EqualSlices[T comparable](s1, s2 []T) bool

func ErrorConditionf

func ErrorConditionf(cond bool, format string, args ...any) error

func EvalLazyArgs

func EvalLazyArgs(args ...any) []any

func Find

func Find[T comparable](lst []T, el T) int

func FindFirstKeyInMap

func FindFirstKeyInMap[K comparable, V any](m map[K]V, cond ...func(k K) bool) (K, bool)

func ForEachUniquePair

func ForEachUniquePair[T any](sl []T, fun func(a1, a2 T) bool)

func GoTh

func GoTh[T Integer](v T) string

func GoThousandsLazy

func GoThousandsLazy[T Integer](v T) func() string

func IsNil

func IsNil(p interface{}) bool

func KeysFiltered

func KeysFiltered[K comparable, V any](m map[K]V, filter func(k K) bool) []K

func KeysSorted

func KeysSorted[K comparable, V any](m map[K]V, less func(k1, k2 K) bool) []K

func List

func List[T any](elems ...T) []T

func MakeErrFuncForPrefix

func MakeErrFuncForPrefix(prefix string) func(err interface{}, args ...interface{}) error

func MakeRange

func MakeRange[T constraints.Integer](from, toIncl T) []T

func Maximum

func Maximum[T any](lst []T, less func(el1, el2 T) bool) T

func Minimum

func Minimum[T any](lst []T, less func(el1, el2 T) bool) T

func MustLastElement

func MustLastElement[T any](sl []T) T

func MustPrivateKeyFromHexString

func MustPrivateKeyFromHexString(k string) ed25519.PrivateKey

func MustTakeFirstKeyInMap

func MustTakeFirstKeyInMap[K comparable, V any](m map[K]V) K

func Panicf

func Panicf(format string, args ...any)

func Percent

func Percent(n, d int) float32

func PercentString

func PercentString(n, d int) string

func PrivateKeyFromHexString

func PrivateKeyFromHexString(k string) (ed25519.PrivateKey, error)

func PurgeSlice

func PurgeSlice[T any](slice []T, filter func(el T) bool, maxElems ...int) []T

PurgeSlice filters elements on the same underlying array

func RangeReverse

func RangeReverse[T any](slice []T, fun func(i int, elem T) bool)

func Ref

func Ref[T any](v T) *T

func RequireErrorWith

func RequireErrorWith(t *testing.T, err error, fragments ...string)

func RequirePanicOrErrorWith

func RequirePanicOrErrorWith(t *testing.T, f func() error, fragments ...string)

func RunWrappedRoutine

func RunWrappedRoutine(name string, fun func(), onPanic func(err error) bool)

func SortKeys

func SortKeys[K comparable, V any](m map[K]V, less func(k1, k2 K) bool) []K

func ValuesFiltered

func ValuesFiltered[K comparable, V any](m map[K]V, filter func(v V) bool) []V

Types

type Integer

type Integer interface {
	int | uint16 | uint32 | uint64 | int16 | int32 | int64
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL