pointer

package
v0.51.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 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.

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 a pointer to a copy of the provided value. A nil, or a value that is already a pointer, 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