ptr

package
v1.11.0 Latest Latest
Warning

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

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

Documentation

Overview

Package ptr contains functions to create references from constant values, typically for representing optional values.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(b bool) *bool

Bool returns a bool pointer.

func BoolEqual

func BoolEqual(p1, p2 *bool) bool

BoolEqual compares two bool pointers for equality.

func Duration

func Duration(n time.Duration) *time.Duration

Duration returns a duration pointer.

func DurationEqual

func DurationEqual(p1, p2 *time.Duration) bool

DurationEqual compares two Duration pointers for equality

func Float64

func Float64(n float64) *float64

Float64 returns a float64 pointer.

func Float64Equal

func Float64Equal(p1, p2 *float64) bool

Float64Equal compares two float64 pointers for equality.

func Int

func Int(n int) *int

Int returns an int pointer.

func Int32

func Int32(n int32) *int32

Int32 returns an int32 pointer

func Int32Equal

func Int32Equal(p1, p2 *int32) bool

Int32Equal compares two int32 pointers for equality.

func Int64

func Int64(n int64) *int64

Int64 returns an int64 pointer

func Int64Equal

func Int64Equal(p1, p2 *int64) bool

Int64Equal compares two int64 pointers for equality.

func IntEqual

func IntEqual(p1, p2 *int) bool

IntEqual compares two int pointers for equality.

func String

func String(s string) *string

String returns a string pointer.

func StringEqual

func StringEqual(p1, p2 *string) bool

StringEqual compares two string pointers for equality.

func Time

func Time(n time.Time) *time.Time

Time returns a time pointer.

func TimeEqual

func TimeEqual(p1, p2 *time.Time) bool

TimeEqual compares two Time pointers for equality

func ToString

func ToString(s *string) string

ToString is a convenience method for dereferencing a string pointer to a string. "" is returned if the pointer is nil.

func ToUInt

func ToUInt(n *uint) uint

ToUInt dereferences a uint pointer to a uint. If the pointer is nil, then returns 0.

func UInt

func UInt(n uint) *uint

UInt returns a uint pointer.

func Unwrap

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

Unwrap derefences a pointer, or returns the zero-value of T if the pointer is nil.

func Wrap

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

Wrap converts a value into a pointer.

Types

This section is empty.

Jump to

Keyboard shortcuts

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