Documentation
¶
Overview ¶
Package utils provides lightweight, generic helpers for slices, zero checks, path expansion, deep copying, and basic filtering.
Index ¶
- func AnyNil[T any](ptrs ...*T) bool
- func DeepCopy[T any](src T) (dst T, err error)
- func DeepCopyPtr[T any](src *T) (*T, error)
- func ExpandHome(path string) string
- func IsSliceEmpty[T ~[]E, E any](ptr T) bool
- func IsSliceNil[T ~[]E, E any](ptr *T) bool
- func IsSliceNilOrEmpty[T ~[]E, E any](ptr *T) bool
- func IsURL(str string) bool
- func IsZero[S comparable](input S) bool
- func PickByIndices[T any](s []T, indices []int) []T
- func SetIfZero[S comparable](input *S, value S)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeepCopyPtr ¶ added in v0.0.13
DeepCopyPtr copies a pointer type object and returns a new pointer to the copied object.
func ExpandHome ¶ added in v0.0.9
ExpandHome resolves home directory references in paths. Replaces leading ~ with the user's home directory path. Returns the original path if expansion fails or isn't needed.
func IsSliceEmpty ¶ added in v0.0.13
IsSliceEmpty checks if a slice is empty.
func IsSliceNil ¶ added in v0.0.13
IsSliceNil checks if a slice pointer is nil.
func IsSliceNilOrEmpty ¶ added in v0.0.13
IsSliceNilOrEmpty checks if a slice pointer is nil or points to an empty slice.
func IsURL ¶
IsURL validates a string as a properly formatted URL. Returns true if the string contains both a scheme and host.
func IsZero ¶ added in v0.0.13
func IsZero[S comparable](input S) bool
IsZero checks if a value equals its type's zero value. Works with any comparable type (numbers, strings, etc.).
func PickByIndices ¶ added in v0.0.11
PickByIndices returns a slice of elements from the input slice based on the provided indices.
func SetIfZero ¶ added in v0.0.13
func SetIfZero[S comparable](input *S, value S)
SetIfZero conditionally updates a pointer's value. Sets the pointed-to value to a new value only if the current value equals the type's zero value.
Types ¶
This section is empty.