ptr

package module
v1.173.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 1 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 NilIfEmpty

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

NilIfEmpty returns v if v is not considered empty; otherwise it returns nil.

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