Documentation
¶
Overview ¶
Package utils provides generic utility functions.
Index ¶
- func Coalesce[T comparable](vals ...T) T
- func DeepCloneMap(src map[string]any) map[string]any
- func DeepCloneSlice(src []any) []any
- func Filter[T any](ts []T, predicate func(T) bool) []T
- func IsBinaryContent(content string) bool
- func Map[T, U any](ts []T, f func(T) U) []U
- func MergeMaps[K comparable, V any](dst, src map[K]V) map[K]V
- func ReadInput(path string) ([]byte, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeepCloneMap ¶
DeepCloneMap creates a deep copy of a map[string]any.
func DeepCloneSlice ¶
DeepCloneSlice creates a deep copy of a slice of interfaces.
func Filter ¶ added in v0.5.0
Filter returns a new slice containing only elements that satisfy the predicate.
func IsBinaryContent ¶ added in v0.5.0
IsBinaryContent checks if the given content appears to be binary data. It uses a simple heuristic: if the content contains null bytes or has a high percentage of non-printable characters, it's likely binary. Note: Valid UTF-8 text (including emojis) is considered text, not binary.
func MergeMaps ¶
func MergeMaps[K comparable, V any](dst, src map[K]V) map[K]V
MergeMaps merges src into dst. Keys in src overwrite dst. Returns new map.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.