ptr

package
v0.0.0-...-23a2324 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2024 License: GPL-3.0 Imports: 0 Imported by: 0

Documentation

Overview

Package ptr provides value to pointer and pointer to value functions.

In most cases, simply use ptr.To or ptr.From functions. There are some extra functions for types which would normally need type conversions from constants, such as ptr.ToInt64.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func From

func From[T any](ref *T) (value T)

From returns the value from a given pointer. If ref is nil, a zero value of type T will be returned.

func FromInt32

func FromInt32(v *int32) int32

FromInt32 is equal to ptr.From(int32(v))

func FromInt64

func FromInt64(v *int64) int64

FromInt64 is equal to ptr.From(int64(v))

func FromOrEmpty

func FromOrEmpty[T any](ref *T) (value T)

FromOrEmpty returns the value or empty value in case the value is nil.

func To

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

To returns a pointer to the given value.

func ToInt32

func ToInt32(v int32) *int32

ToInt32 is equal to ptr.To(int32(v))

func ToInt64

func ToInt64(v int64) *int64

ToInt64 is equal to ptr.To(int64(v))

Types

This section is empty.

Jump to

Keyboard shortcuts

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