generic

package
v1.0.43 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2025 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyOptions

func ApplyOptions[K any, T ~func(*K)](in ...T) K

func ApplyOptionsError

func ApplyOptionsError[K any, T ~func(*K) error](in ...T) (K, []error)

func ApplyOptionsErrorWithDefault

func ApplyOptionsErrorWithDefault[K any, T ~func(*K) error](k K, in ...T) (K, []error)

func ApplyOptionsWithDefault

func ApplyOptionsWithDefault[K any, T ~func(*K)](k K, in ...T) K

func AreAllEmpty

func AreAllEmpty[T comparable](in ...T) bool

func AreAllNil

func AreAllNil[T any](in ...*T) bool

func AreAllPointerValuesEqual

func AreAllPointerValuesEqual[T comparable](v ...*T) bool

func CopyMap

func CopyMap[V comparable, T any](in map[V]T) map[V]T

func DefaultOnEmpty

func DefaultOnEmpty[T comparable](in, def T) T

func DefaultOnNilPointer

func DefaultOnNilPointer[T any](in *T, def T) T

func Deref

func Deref[T any](in *T) T

func Empty

func Empty[T any]() T

func FilterSlice

func FilterSlice[T any](in []T, filter func(in T) bool) []T

func FindOne

func FindOne[T any](in []T, filter func(in T) bool) (r T, _ bool)

func FirstNotNil

func FirstNotNil[T any](v ...*T) *T

func GetSliceElementByIndexOrDefault

func GetSliceElementByIndexOrDefault[T any](in []T, index int, defaultValue T) T

func IsEmpty

func IsEmpty[T comparable](in T) bool

func IsOneOf

func IsOneOf[T comparable](val T, values ...T) bool

func MapKeysToSlice

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

K = key, V = value

func MapToPointerSlice

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

K = key, V = value

func MapToSlice

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

K = key, V = value

func MergeMaps

func MergeMaps[V comparable, T any](maps ...map[V]T) map[V]T

func Must

func Must[T any](in T, err error) T

func Pointer

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

func PointerMapToPointerSlice

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

K = key, V = value

func PointerMapToSlice

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

K = key, V = value

func SliceContains

func SliceContains[T any](in []T, check func(in T) bool) bool

func SliceToMap

func SliceToMap[K comparable, V any](slice []V, keyFromValue func(v V, i int) K) map[K]V

K = key, V = value

func SliceToMapErr

func SliceToMapErr[K comparable, V any](slice []V, keyFromValue func(v V, i int) (K, error)) (map[K]V, error)

K = key, V = value

func SliceToMapKeys

func SliceToMapKeys[K comparable, V any](slice []V, keyFromValue func(v V) K) map[K]any

K = key

func Some

func Some[T any](in T, err error) T

func Ternary

func Ternary[T any, C ~bool](condition C, v1, v2 T) T

func ToAny

func ToAny[T any](in T) any

func TransformMapToSlice

func TransformMapToSlice[K comparable, V, T any](in map[K]V, transform func(k K, v V) T) []T

func TransformSlice

func TransformSlice[T, K any](in []T, transform func(in T) K) []K

func TransformSliceErr

func TransformSliceErr[T, K any](in []T, transform func(in T) (K, error)) ([]K, error)

func TransformSliceToMap

func TransformSliceToMap[K comparable, V, T any](in []T, transform func(e T, i int) (K, V)) map[K]V

Types

type Option

type Option[T any] func(*T)

func If

func If[T any](cond bool, in ...Option[T]) Option[T]

func WithOptions

func WithOptions[T any](in ...Option[T]) Option[T]

type OptionError

type OptionError[T any] func(*T) error

Jump to

Keyboard shortcuts

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