Documentation
¶
Index ¶
- func Keys[K comparable, V any](m map[K]V) []K
- func Ptr[T any](value T) *T
- func PtrOrNil[T comparable](t T) *T
- func SortedKeys[K cmp.Ordered, V any](m map[K]V) []K
- func UniqueSlice[T comparable](items []T) []T
- func UniqueSliceByKey[T any](items []T, getKey func(T) string) []T
- func ValueOrZero[T any](ptr *T) T
- func Values[K comparable, V any](m map[K]V) []V
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PtrOrNil ¶
func PtrOrNil[T comparable](t T) *T
PtrOrNil returns a pointer to t if it has a non-empty value otherwise nil.
func SortedKeys ¶
SortedKeys returns a slice of keys from m map in sorted order (ascending).
func UniqueSlice ¶
func UniqueSlice[T comparable](items []T) []T
UniqueSlice returns a slice without duplicate elements.
func UniqueSliceByKey ¶
UniqueSliceByKey returns a slice without duplicate elements using a custom get key function.
func ValueOrZero ¶
func ValueOrZero[T any](ptr *T) T
ValueOrZero returns the value that the pointer ptr pointers to. It returns the zero value if ptr is nil.
func Values ¶
func Values[K comparable, V any](m map[K]V) []V
Values returns a slice of values from m map.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.