utils

package
v2.0.0-...-82fddbe Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2025 License: MIT Imports: 7 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NotFound = errors.New("not found")

Functions

func AllAreNil

func AllAreNil(ptrs ...any) bool

func CountNotNil

func CountNotNil(ptrs ...any) int

func Default

func Default[T any](t *T, defaultValue T) T

func IsPointer

func IsPointer[T any](v T) bool

func Jitter

func Jitter() time.Duration

func JitterFunc

func JitterFunc(min *int, maxMinusMin *int) func() time.Duration

func NonNil

func NonNil[T any](ptrs []*T) []T

func NoneAreNil

func NoneAreNil(ptrs ...any) bool

func OneIsDefined

func OneIsDefined(ptrs ...any) bool

func Pointer

func Pointer[T any](t T) *T

func PtrContains

func PtrContains[T comparable](t *T, value T) bool

func Retry

func Retry[T any](f func() (T, error)) (t T, err error)

func RetryTimes

func RetryTimes[T any](numRetries int, f func() (T, error)) (t T, err error)

Types

type ErrAnd

type ErrAnd[T any] struct {
	Item T
	Err  error
}

func ErrAndT

func ErrAndT[T any](t T) ErrAnd[T]

func TandErr

func TandErr[T any](t T, err error) ErrAnd[T]

type Result

type Result[T any] struct {
	Item *T
	Err  error
}

func ErroredResult

func ErroredResult[T any](err error) Result[T]

func ResultFrom

func ResultFrom[T any](t T, err error) Result[T]

func SuccessfulResult

func SuccessfulResult[T any](t T) Result[T]

type Set

type Set[T comparable] map[T]struct{}

func MapUniqueChildren

func MapUniqueChildren[T any, U comparable](allItems []T, getChild func(T) U) Set[U]

TODO: TEST ME

func SetFrom

func SetFrom[T comparable](ts ...T) Set[T]

func SetOf

func SetOf[T comparable](items []T) Set[T]

SetOf returns a set only containing unique values of items passed in

func (Set[T]) Add

func (s Set[T]) Add(es ...T)

func (Set[T]) Contains

func (s Set[T]) Contains(el T) bool

func (Set[T]) MarshalJSON

func (s Set[T]) MarshalJSON() ([]byte, error)

func (Set[T]) Remove

func (s Set[T]) Remove(el T)

func (Set[T]) ToSlice

func (s Set[T]) ToSlice() []T

func (*Set[T]) UnmarshalJSON

func (s *Set[T]) UnmarshalJSON(data []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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