utils

package
v1.11.13-rc.2 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2024 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Err

func Err(errors ...error) error

func GetStacktrace

func GetStacktrace(all bool) string

func IsSortedAndUnique

func IsSortedAndUnique[T Sortable[T]](s []T) bool

Returns true iff the elements in [s] are unique and sorted.

func IsSortedAndUniqueByHash

func IsSortedAndUniqueByHash[T ~[]byte](s []T) bool

Returns true iff the elements in [s] are unique and sorted based by their hashes.

func IsSortedAndUniqueOrdered

func IsSortedAndUniqueOrdered[T cmp.Ordered](s []T) bool

Returns true iff the elements in [s] are unique and sorted.

func IsSortedBytes

func IsSortedBytes[T ~[]byte](s []T) bool

Returns true iff the elements in [s] are sorted.

func RandomBytes

func RandomBytes(n int) []byte

RandomBytes returns a slice of n random bytes Intended for use in testing

func Sort

func Sort[T Sortable[T]](s []T)

Sorts the elements of [s].

func SortByHash

func SortByHash[T ~[]byte](s []T)

Sorts the elements of [s] based on their hashes.

func Zero

func Zero[T any]() T

Returns a new instance of a T.

func ZeroSlice

func ZeroSlice[T any](s []T)

ZeroSlice sets all values of the provided slice to the type's zero value.

This can be useful to ensure that the garbage collector doesn't hold references to values that are no longer desired.

Types

type Atomic

type Atomic[T any] struct {
	// contains filtered or unexported fields
}

func (*Atomic[T]) Get

func (a *Atomic[T]) Get() T

func (*Atomic[T]) Set

func (a *Atomic[T]) Set(value T)

type Sortable

type Sortable[T any] interface {
	Compare(T) int
}

Directories

Path Synopsis
crypto
bls
keychain
Package keychain is a generated GoMock package.
Package keychain is a generated GoMock package.
Package filesystem is a generated GoMock package.
Package filesystem is a generated GoMock package.
Package hashing is a generated GoMock package.
Package hashing is a generated GoMock package.
Package resource is a generated GoMock package.
Package resource is a generated GoMock package.

Jump to

Keyboard shortcuts

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