ptr

package
v0.13.2 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package ptr provides tiny generic helpers for working with pointers, so callers stop writing one-off "address of a literal" locals or nil-checking deref blocks. It is dependency-free.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Deref

func Deref[T any](p *T) T

Deref returns the value p points to, or the zero value of T when p is nil.

func DerefOr

func DerefOr[T any](p *T, def T) T

DerefOr returns the value p points to, or def when p is nil.

func To

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

To returns a pointer to v. It is the idiomatic way to take the address of a literal or a function result (for example an optional struct field or a pointer-typed API argument) without an intermediate local variable.

Types

This section is empty.

Jump to

Keyboard shortcuts

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