Categorygithub.com/gotidy/ptr
modulepackage
1.4.0
Repository: https://github.com/gotidy/ptr.git
Documentation: pkg.go.dev

# README

ptr GoDoc Go Report Card Mentioned in Awesome Go

ptr contains functions for simplified creation of pointers from constants of basic types.

Support for generics has been implemented since version 1.4.0. Required 1.18 or later version of Go.

Installation

go get github.com/gotidy/ptr

Examples

This code:

p := ptr.Of(10)

is the equivalent for:

i := int(10)
p := &i  

Documentation

GoDoc

License

Apache 2.0

# Functions

Bool returns pointer to bool value.
Byte returns pointer to byte value.
Complex128 returns pointer to complex128 value.
Complex64 returns pointer to complex64 value.
Duration returns pointer to time.Duration value.
Float32 returns pointer to float32 value.
Float64 returns pointer to float64 value.
Int returns pointer to int value.
Int16 returns pointer to int16 value.
Int32 returns pointer to int32 value.
Int64 returns pointer to int64 value.
Int8 returns pointer to int8 value.
Of returns pointer to value.
Rune returns pointer to rune value.
String returns pointer to string value.
Time returns pointer to time.Time value.
To returns the value of the pointer passed in or the default value if the pointer is nil.
ToBool returns the value of the bool pointer passed in or false if the pointer is nil.
ToBoolDef returns the value of the bool pointer passed in or default value if the pointer is nil.
ToByte returns the value of the byte pointer passed in or 0 if the pointer is nil.
ToByteDef returns the value of the byte pointer passed in or default value if the pointer is nil.
ToComplex128 returns the value of the complex128 pointer passed in or 0 if the pointer is nil.
ToComplex128Def returns the value of the complex128 pointer passed in or default value if the pointer is nil.
ToComplex64 returns the value of the complex64 pointer passed in or 0 if the pointer is nil.
ToComplex64Def returns the value of the complex64 pointer passed in or default value if the pointer is nil.
ToDef returns the value of the int pointer passed in or default value if the pointer is nil.
ToDuration returns the value of the time.Duration pointer passed in or 0 if the pointer is nil.
ToDurationDef returns the value of the time.Duration pointer passed in or default value if the pointer is nil.
ToFloat32 returns the value of the float32 pointer passed in or 0 if the pointer is nil.
ToFloat32Def returns the value of the float32 pointer passed in or default value if the pointer is nil.
ToFloat64 returns the value of the float64 pointer passed in or 0 if the pointer is nil.
ToFloat64Def returns the value of the float64 pointer passed in or default value if the pointer is nil.
ToInt returns the value of the int pointer passed in or int if the pointer is nil.
ToInt16 returns the value of the int16 pointer passed in or 0 if the pointer is nil.
ToInt16Def returns the value of the int16 pointer passed in or default value if the pointer is nil.
ToInt32 returns the value of the int32 pointer passed in or 0 if the pointer is nil.
ToInt32Def returns the value of the int32 pointer passed in or default value if the pointer is nil.
ToInt64 returns the value of the int64 pointer passed in or 0 if the pointer is nil.
ToInt64Def returns the value of the int64 pointer passed in or default value if the pointer is nil.
ToInt8 returns the value of the int8 pointer passed in or 0 if the pointer is nil.
ToInt8Def returns the value of the int8 pointer passed in or default value if the pointer is nil.
ToIntDef returns the value of the int pointer passed in or default value if the pointer is nil.
ToRune returns the value of the rune pointer passed in or 0 if the pointer is nil.
ToRuneDef returns the value of the rune pointer passed in or default value if the pointer is nil.
ToString returns the value of the string pointer passed in or empty string if the pointer is nil.
ToStringDef returns the value of the string pointer passed in or default value if the pointer is nil.
ToTime returns the value of the time.Time pointer passed in or Time{} if the pointer is nil.
ToTimeDef returns the value of the time.Time pointer passed in or default value if the pointer is nil.
ToUInt returns the value of the uint pointer passed in or 0 if the pointer is nil.
ToUInt16 returns the value of the uint16 pointer passed in or 0 if the pointer is nil.
ToUInt16Def returns the value of the uint16 pointer passed in or default value if the pointer is nil.
ToUInt32 returns the value of the uint32 pointer passed in or 0 if the pointer is nil.
ToUInt32Def returns the value of the uint32 pointer passed in or default value if the pointer is nil.
ToUInt64 returns the value of the uint64 pointer passed in or 0 if the pointer is nil.
ToUInt64Def returns the value of the uint64 pointer passed in or default value if the pointer is nil.
ToUInt8 returns the value of the uint8 pointer passed in or 0 if the pointer is nil.
ToUInt8Def returns the value of the uint8 pointer passed in or default value if the pointer is nil.
ToUIntDef returns the value of the uint pointer passed in or default value if the pointer is nil.
UInt returns pointer to uint value.
UInt16 returns pointer to uint16 value.
UInt32 returns pointer to uint32 value.
UInt64 returns pointer to uint64 value.
UInt8 returns pointer to uint8 value.