utils

package module
v1.5.0 Latest Latest
Warning

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

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

README

go-utils

Useful functions for go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All added in v1.1.0

func All[I any, L ~[]I](items L, f func(I) bool) bool

func AllE added in v1.1.0

func AllE[I any, L ~[]I](items L, f func(I) (bool, error)) (bool, error)

func Any added in v1.1.0

func Any[I any, L ~[]I](items L, f func(I) bool) bool

func AnyE added in v1.1.0

func AnyE[I any, L ~[]I](items L, f func(I) (bool, error)) (bool, error)

func ArrayIntersection added in v1.3.0

func ArrayIntersection[I comparable, L ~[]I](slices ...L) L

func Contains

func Contains[I comparable, L ~[]I](item I, items L) bool

func Filter added in v1.1.0

func Filter[I any, L ~[]I](items L, f func(I) bool) []I

func FilterE added in v1.1.0

func FilterE[I any, L ~[]I](items L, f func(I) (bool, error)) ([]I, error)

func Find

func Find[I any, L ~[]I](items L, f func(I) bool) (i I, ok bool)

func FindE

func FindE[I any, L ~[]I](items L, f func(I) (bool, error)) (i I, ok bool, err error)

func GroupBy

func GroupBy[I any, L ~[]I, K comparable](items L, f func(I) K) map[K]L

func GroupByE

func GroupByE[I any, L ~[]I, K comparable](items L, f func(I) (K, error)) (map[K]L, error)

func Intersection

func Intersection[I comparable, L ~[]I](items1 L, items2 L) map[I]struct{}

func Map

func Map[I any, L ~[]I, K comparable](items L, f func(I) K) map[K]I

func MapE

func MapE[I any, L ~[]I, K comparable](items L, f func(I) (K, error)) (map[K]I, error)

func MapKeys added in v1.5.0

func MapKeys[K comparable, V any](items map[K]V) []K

func MapS

func MapS[I any, L ~[]I, K comparable](items L, f func(I) K) []struct {
	K K
	I I
}

func MapSE

func MapSE[I any, L ~[]I, K comparable](items L, f func(I) (K, error)) ([]struct {
	K K
	I I
}, error)

func MapValues added in v1.5.0

func MapValues[K comparable, V any](items map[K]V) []V

func MapsIsEqual

func MapsIsEqual[K comparable, V comparable](a, b map[K]V) bool

func NullUUIDToP

func NullUUIDToP(id uuid.NullUUID) *uuid.UUID

func P

func P[T any](v T) *T

func PToNullUUID

func PToNullUUID(id *uuid.UUID) uuid.NullUUID

func Reduce added in v1.2.0

func Reduce[I any, L ~[]I, R any](items L, f func(R, I) R, initial R) R

func ReduceE added in v1.2.0

func ReduceE[I any, L ~[]I, R any](items L, f func(R, I) (R, error), initial R) (R, error)

func Select

func Select[I any, L ~[]I, T any](items L, f func(I) T) []T

func SelectE

func SelectE[I any, L ~[]I, T any](items L, f func(I) (T, error)) ([]T, error)

func Set added in v1.5.0

func Set[I any, L ~[]I, K comparable](items L, f func(I) K) map[K]struct{}

func SetE added in v1.5.0

func SetE[I any, L ~[]I, K comparable](items L, f func(I) (K, error)) (map[K]struct{}, error)

func T

func T[T any](value bool, trueValue T, falseValue T) T

func TF

func TF[T any](value bool, trueValue func() T, falseValue func() T) T

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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