Documentation ¶
Overview ¶
Package z exposes a curated set of utility functions.
Its primary goals are two-fold:
- Make the best commonly used utilities discoverable
- Reduce hand strain; "I can finally stop writing `func must(...)` everywhere!"
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddToMap ¶
func AddToMap[K comparable, V any](m map[K]V, k K, v V) map[K]V
AddToMap will add the key value pair to the map, ensuring that the map is not nil.
func ConcatMaps ¶
func ConcatMaps[K comparable, V any](ms ...map[K]V) map[K]V
ConcatMaps will iteratively add all the key/value pairs from each map, overwriting existing keys. That is, if every map in ms has the same key, then the value of that key in the resulting map will be the value of the key in the last map in ms. If no maps are provided, then a nil map is returned. If at least one map is provided (nil or not), then a non-nil map is returned.
func Dereference ¶
func Dereference[T any](p *T) (v T)
Dereference returns the dereferenced value of p. If p is nil, the zero value of T is returned instead. This function is intended to be used to dereference native types (e.g. *int, *string, etc.); for structs, use of Dereference may decrease readability and obscure intent, so prefer a conditional (e.g. `if p != nil { ... }`) instead.
Types ¶
This section is empty.