utils

package
v1.10.6-rc.6 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2023 License: BSD-3-Clause Imports: 9 Imported by: 85

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Detach added in v1.9.4

func Detach(ctx context.Context) context.Context

func GetStacktrace added in v1.8.4

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 added in v1.9.4

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

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

func IsSortedAndUniqueOrdered added in v1.9.4

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

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

func IsSortedBytes added in v1.10.3

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

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

func IsUnique added in v1.9.4

func IsUnique[T comparable](s []T) bool

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

func RandomBytes

func RandomBytes(n int) []byte

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

func Sort added in v1.9.4

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

Sorts the elements of [s].

func SortByHash added in v1.9.4

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

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

func SortBytes added in v1.9.4

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

Sorts a 2D byte slice. Each byte slice is not sorted internally; the byte slices are sorted relative to one another.

func Zero added in v1.8.4

func Zero[T any]() T

Returns a new instance of a T.

Types

type Atomic added in v1.9.8

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

func (*Atomic[T]) Get added in v1.9.8

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

func (*Atomic[T]) Set added in v1.9.8

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

type Sortable added in v1.9.4

type Sortable[T any] interface {
	Less(T) bool
}

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 logging is a generated GoMock package.
Package logging 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