pointer

package
v0.35.0 Latest Latest
Warning

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

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

README

pointer

A single helper, pointer.To(value any) any, that returns a pointer to its argument (and returns the value unchanged if it is already a pointer or interface). Part of rosetta.

What matters here

  • To is reflection-based and untyped (any in, any out). It exists for cases where the type isn't known at compile time (e.g. building values dynamically for the schema engine). When the type is known, prefer the generic convert.Pointer[T](v) *T, which is type-safe and avoids reflection — convert owns the generic pointer/dereference helpers (Pointer, Element), not this package.
  • Already-pointer and interface inputs pass through unchanged, so To is idempotent — calling it on a *T returns the same *T, not a **T.

Documentation

Overview

Package pointer returns a pointer to a value whose type is not known at compile time.

To is reflection-based and untyped — any in, any out — which is what makes it usable when building values dynamically for the schema engine. Inputs that are already pointers or interfaces pass through unchanged, so To is idempotent and never produces a pointer to a pointer.

When the type is known at compile time, prefer convert.Pointer, which is generic, type-safe, and skips the reflection entirely. The convert package owns the typed pointer helpers; this package exists only for the untyped case.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func To

func To(value any) any

To returns the provided value as a pointer to the original. If the provided value is already a pointer, it is returned as-is.

Types

This section is empty.

Jump to

Keyboard shortcuts

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