ptr

package
v1.148.0 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

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 To

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

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.

Jump to

Keyboard shortcuts

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