ptrx

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package ptrx holds the pointer helpers Go's optional-field style forces on every service: taking the address of a literal, and reading through a possibly-nil pointer. The stdlib has no answer (k8s.io/utils/ptr exists precisely because of that gap).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatOr

func FormatOr[T any](p *T, fallback string) string

FormatOr renders *p with fmt.Sprint, or fallback when p is nil — for logs where a nil optional should read as something ("default", "unset") instead of a pointer literal or a misleading zero.

func To

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

To returns a pointer to v — the "address of a literal" helper that makes optional struct fields writable in one expression: Enabled: ptrx.To(true).

func Value

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

Value returns *p, or T's zero value when p is nil.

Types

This section is empty.

Jump to

Keyboard shortcuts

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