Documentation
¶
Overview ¶
Package ptr provides utilities for working with pointers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Deref ¶
func Deref[T any](v *T) T
Deref returns the value pointed to by v.
It is an alias for From.
func From ¶
func From[T any](v *T) T
From returns the value pointed to by v.
If v is nil, it returns the zero value of T.
func FromOrDefault ¶
func FromOrDefault[T any](v *T, defaultValue T) T
FromOrDefault returns the value pointed to by v.
If v is nil, it returns defaultValue instead.
func ToOrNilIfEmpty ¶
func ToOrNilIfEmpty[T any](v T) *T
ToOrNilIfEmpty returns a pointer to v if v is not considered empty; otherwise it returns nil.
Emptiness is determined via utils/reflection.IsEmpty (e.g. "", whitespace-only strings, 0, false, nil, empty slices/maps, etc.).
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.