Documentation ¶
Overview ¶
Package pointer is an attempt to provide functions to convert data to pointers using generics. inspired by https://pkg.go.dev/github.com/aws/smithy-go/ptr This is intended to replace the following patterns that we've seen across our codebase: - myVar := "value"; return &myVar - ptr.{SomeType}("value") Also Enables the possibility to use: var res *myStructType = ToPtr(myStructType{}) and any derivate with map / slice
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ToMapPtr ¶
func ToMapPtr[K comparable, T any](objectMap map[K]T) map[K]*T
ToMapPtr returns a map of pointers of type *T pointing to each element of {objectMap}
func ToMapValue ¶
func ToMapValue[K comparable, T any](ptrs map[K]*T) map[K]T
ToSliceValue returns a map of values of type T pointed by each pointers in {ptrs} if a pointer in {ptrs} is nil the value at the corresponding key will be the 0 of T
func ToSlicePtr ¶
func ToSlicePtr[T any](objects []T) []*T
ToSlicePtr returns a slice of pointers of type *T pointing to each element of {objects}
func ToSliceValue ¶
func ToSliceValue[T any](ptrs []*T) []T
ToSliceValue returns a slice of values of type T pointed by each pointers in {ptrs} if a pointer in {ptrs} is nil the value at the corresponding index will be the 0 of T
Types ¶
This section is empty.