pointer

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2022 License: MIT Imports: 2 Imported by: 0

README

pointer

Pointer is a collection of helpers providing value-to-pointer/pointer-to-value conversions for basic Golang types.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(v bool) *bool

Bool creates a pointer to the provided boolean value

func BoolVal

func BoolVal(ptr *bool) (val bool, ok bool)

BoolVal returns the value of the boolean pointer and "true" or "false" and "false" if the pointer is nil

func Byte

func Byte(v byte) *byte

Byte creates a pointer to the provided byte value

func ByteVal

func ByteVal(ptr *byte) (val byte, ok bool)

ByteVal returns the value of the byte pointer and "true" or 0 and "false" if the pointer is nil

func Complex64

func Complex64(v complex64) *complex64

Complex64 creates a pointer to the provided complex64 value

func Complex64Val

func Complex64Val(ptr *complex64) (val complex64, ok bool)

Complex64Val returns the value of the complex64 pointer and "true" or 0 and "false" if the pointer is nil

func Complex128

func Complex128(v complex128) *complex128

Complex128 creates a pointer to the provided complex128 value

func Complex128Val

func Complex128Val(ptr *complex128) (val complex128, ok bool)

Complex128Val returns the value of the complex128 pointer and "true" or 0 and "false" if the pointer is nil

func Duration

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

Duration creates a pointer to the provided time.Duration value

func DurationVal

func DurationVal(ptr *time.Duration) (val time.Duration, ok bool)

DurationVal returns the value of the time.Duration pointer and "true" or 0 and "false" if the pointer is nil

func Float32

func Float32(v float32) *float32

Float32 creates a pointer to the provided float32 value

func Float32Val

func Float32Val(ptr *float32) (val float32, ok bool)

Float32Val returns the value of the float32 pointer and "true" or 0 and "false" if the pointer is nil

func Float64

func Float64(v float64) *float64

Float64 creates a pointer to the provided float64 value

func Float64Val

func Float64Val(ptr *float64) (val float64, ok bool)

Float64Val returns the value of the float64 pointer and "true" or 0 and "false" if the pointer is nil

func Int

func Int(v int) *int

Int creates a pointer to the provided int value

func Int8

func Int8(v int8) *int8

Int8 creates a pointer to the provided int8 value

func Int8Val

func Int8Val(ptr *int8) (val int8, ok bool)

Int8Val returns the value of the int8 pointer and "true" or 0 and "false" if the pointer is nil

func Int16

func Int16(v int16) *int16

Int16 creates a pointer to the provided int16 value

func Int16Val

func Int16Val(ptr *int16) (val int16, ok bool)

Int16Val returns the value of the int16 pointer and "true" or 0 and "false" if the pointer is nil

func Int32

func Int32(v int32) *int32

Int32 creates a pointer to the provided int32 value

func Int32Val

func Int32Val(ptr *int32) (val int32, ok bool)

Int32Val returns the value of the int32 pointer and "true" or 0 and "false" if the pointer is nil

func Int64

func Int64(v int64) *int64

Int64 creates a pointer to the provided int64 value

func Int64Val

func Int64Val(ptr *int64) (val int64, ok bool)

Int64Val returns the value of the int64 pointer and "true" or 0 and "false" if the pointer is nil

func IntVal

func IntVal(ptr *int) (val int, ok bool)

IntVal returns the value of the int pointer and "true" or 0 and "false" if the pointer is nil

func Interface

func Interface(v interface{}) *interface{}

Interface creates a pointer to the provided interface{} value

func InterfaceVal

func InterfaceVal(ptr *interface{}) (val interface{}, ok bool)

InterfaceVal returns the value of the interface{} pointer and "true" or nil and "false" if the pointer is nil

func Pointer added in v1.1.0

func Pointer[T any](val T) *T

Pointer returns a pointer to provided value.

func Rune

func Rune(v rune) *rune

Rune creates a pointer to the provided rune value

func RuneVal

func RuneVal(ptr *rune) (val rune, ok bool)

RuneVal returns the value of the rune pointer and "true" or 0 and "false" if the pointer is nil

func String

func String(v string) *string

String creates a pointer to the provided string value

func StringVal

func StringVal(ptr *string) (val string, ok bool)

StringVal returns the value of the string pointer and "true" or an empty string

and "false" if the pointer is nil

func Time

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

Time creates a pointer to the provided time.Time value

func TimeVal

func TimeVal(ptr *time.Time) (val time.Time, ok bool)

TimeVal returns the value of the time.Time pointer and "true" or zero time.Time and "false" if the pointer is nil

func Uint

func Uint(v uint) *uint

Uint creates a pointer to the provided uint value

func Uint8

func Uint8(v uint8) *uint8

Uint8 creates a pointer to the provided uint8 value

func Uint8Val

func Uint8Val(ptr *uint8) (val uint8, ok bool)

Uint8Val returns the value of the uint8 pointer and "true" or 0 and "false" if the pointer is nil

func Uint16

func Uint16(v uint16) *uint16

Uint16 creates a pointer to the provided uint16 value

func Uint16Val

func Uint16Val(ptr *uint16) (val uint16, ok bool)

Uint16Val returns the value of the uint16 pointer and "true" or 0 and "false" if the pointer is nil

func Uint32

func Uint32(v uint32) *uint32

Uint32 creates a pointer to the provided uint32 value

func Uint32Val

func Uint32Val(ptr *uint32) (val uint32, ok bool)

Uint32Val returns the value of the uint32 pointer and "true" or 0 and "false" if the pointer is nil

func Uint64

func Uint64(v uint64) *uint64

Uint64 creates a pointer to the provided uint64 value

func Uint64Val

func Uint64Val(ptr *uint64) (val uint64, ok bool)

Uint64Val returns the value of the uint64 pointer and "true" or 0 and "false" if the pointer is nil

func UintVal

func UintVal(ptr *uint) (val uint, ok bool)

UintVal returns the value of the uint pointer and "true" or 0 and "false" if the pointer is nil

func Uintptr

func Uintptr(v uintptr) *uintptr

Uintptr creates a pointer to the provided uintptr value

func UintptrVal

func UintptrVal(ptr *uintptr) (val uintptr, ok bool)

UintptrVal returns the value of the uintptr pointer and "true" or 0 and "false" if the pointer is nil

func Unpoint

func Unpoint(v interface{}) interface{}

Unpoint returns actual value of the pointers

func Value added in v1.1.0

func Value[T any](ptr *T) (T, bool)

Value returns pointer value and true if not nil or zero value and false.

Types

This section is empty.

Jump to

Keyboard shortcuts

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