ptr

package
v2.11.2 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(v bool) *bool

func Copy

func Copy[T any](p *T) (ret *T)

Copy returns a shallow copy of the given pointer of any type. If p is nil, it returns nil.

func Deref

func Deref[T any](p *T) (ret T)

Deref returns the value pointed by pointer p. If p is nil, it returns zero value of type T.

func DerefBool

func DerefBool(v *bool) bool

func DerefDuration

func DerefDuration(v *time.Duration) time.Duration

func DerefFloat32

func DerefFloat32[T constraints.RealNumber](v *T) (ret float32)

func DerefFloat64

func DerefFloat64[T constraints.RealNumber](v *T) (ret float64)

func DerefInt

func DerefInt[T constraints.Integer](v *T) (ret int)

func DerefInt16

func DerefInt16[T constraints.Integer](v *T) (ret int16)

func DerefInt32

func DerefInt32[T constraints.Integer](v *T) (ret int32)

func DerefInt64

func DerefInt64[T constraints.Integer](v *T) (ret int64)

func DerefInt8

func DerefInt8[T constraints.Integer](v *T) (ret int8)

func DerefString

func DerefString[T ~string](v *T) string

func DerefTime

func DerefTime(v *time.Time) time.Time

func DerefUint

func DerefUint[T constraints.Integer](v *T) (ret uint)

func DerefUint16

func DerefUint16[T constraints.Integer](v *T) (ret uint16)

func DerefUint32

func DerefUint32[T constraints.Integer](v *T) (ret uint32)

func DerefUint64

func DerefUint64[T constraints.Integer](v *T) (ret uint64)

func DerefUint8

func DerefUint8[T constraints.Integer](v *T) (ret uint8)

func Duration

func Duration(v time.Duration) *time.Duration

func Float32

func Float32[T constraints.RealNumber](v T) *float32

func Float64

func Float64[T constraints.RealNumber](v T) *float64

func Int

func Int[T constraints.Integer](v T) *int

func Int16

func Int16[T constraints.Integer](v T) *int16

func Int32

func Int32[T constraints.Integer](v T) *int32

func Int64

func Int64[T constraints.Integer](v T) *int64

func Int8

func Int8[T constraints.Integer](v T) *int8

func IntToStringp

func IntToStringp[T constraints.Integer](x T) *string

IntToStringp converts Integer x to a string pointer.

func IntpToString

func IntpToString[T constraints.Integer](x *T) string

IntpToString converts x to a string. It returns an empty string if x is nil.

func IntpToStringp

func IntpToStringp[T constraints.Integer](x *T) *string

IntpToStringp converts x to a string pointer. It returns nil if x is nil.

func NotZero added in v2.3.1

func NotZero[T comparable](v T) (ret *T)

NotZero returns a pointer to v if v is not zero value of it's type, else it returns nil.

func Ptr

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

Ptr returns copies v of any type and returns a pointer.

func String

func String[T ~string | constraints.Integer](v T) *string

func Time

func Time(v time.Time) *time.Time

func Uint

func Uint[T constraints.Integer](v T) *uint

func Uint16

func Uint16[T constraints.Integer](v T) *uint16

func Uint32

func Uint32[T constraints.Integer](v T) *uint32

func Uint64

func Uint64[T constraints.Integer](v T) *uint64

func Uint8

func Uint8[T constraints.Integer](v T) *uint8

Types

This section is empty.

Jump to

Keyboard shortcuts

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