Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Copy ¶
func Copy[T any](in *T) *T
Copy copies value behind the pointer and returns a new pointer to the copy.
func To ¶
func To[T any](t T) *T
To returns a pointer to value. This function is very useful for single-line expressions, where "&" cannot be used:
in := Input{
RequiredField: "works"
OptionalField: ptr.To("this also works")
}
func Value ¶
func Value[T any](ptr *T) T
Value returns a value behind the pointer or zero value when value is nil.
func ValueOrDefault ¶
func ValueOrDefault[T any](ptr *T, defaultValue T) T
ValueOrDefault returns a value behind the pointer or defaultValue when value is nil.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.