utils

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2023 License: BSD-3-Clause Imports: 11 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyBytes

func CopyBytes(b []byte) []byte

CopyBytes returns a copy of the provided byte slice. If nil is provided, nil will be returned.

func Detach

func Detach(ctx context.Context) context.Context

func GetStacktrace

func GetStacktrace(all bool) string

func IsSortedAndUnique deprecated

func IsSortedAndUnique(data sort.Interface) bool

IsSortedAndUnique returns true if the elements in the data are unique and sorted.

Deprecated: Use one of the other [IsSortedAndUnique...] functions instead.

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 constraints.Ordered](s []T) bool

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

func IsSortedAndUniqueSortable

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

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

func IsUnique

func IsUnique[T comparable](elts []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

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 SortBytes

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

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

func Zero

func Zero[T any]() T

Returns a new instance of a T.

Types

type AtomicBool

type AtomicBool struct {
	// contains filtered or unexported fields
}

func (*AtomicBool) GetValue

func (a *AtomicBool) GetValue() bool

func (*AtomicBool) SetValue

func (a *AtomicBool) SetValue(b bool)

type AtomicInterface

type AtomicInterface struct {
	// contains filtered or unexported fields
}

func NewAtomicInterface

func NewAtomicInterface(v interface{}) *AtomicInterface

func (*AtomicInterface) GetValue

func (a *AtomicInterface) GetValue() interface{}

func (*AtomicInterface) SetValue

func (a *AtomicInterface) SetValue(v interface{})

type Sortable

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

Directories

Path Synopsis
bls
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