ptr

package
v0.0.0-...-696d021 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2025 License: Apache-2.0 Imports: 0 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Equal

func Equal[T comparable](a, b *T) bool

Equal returns true if both arguments are nil or both arguments dereference to the same value.

func Ptr

func Ptr[T any](v T) *T

Ptr returns a pointer to the given value.

func ToAny

func ToAny[T any](v T) *any

ToAny converts a value of any type to a pointer to interface{}. It first converts the value to interface{} and then returns a pointer to it.

func ValOrDef

func ValOrDef[T any](ptr *T, def T) T

ValOrDef dereferences ptr and returns the value it points to if non-nil, or returns the provided default value if ptr is nil.

func ValOrZero

func ValOrZero[T any](ptr *T) T

ValOrZero returns the pointer's value if non-nil, or the zero value of type T if nil.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL