ptr

package module
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2020 License: Apache-2.0 Imports: 1 Imported by: 40 modules, 85 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

ptr GoDoc Go Report Card

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

Installation

go get github.com/gotidy/ptr

Examples

This code:

p := ptr.Int(10)

is the equivalent for:

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

Documentation

GoDoc

License

Apache 2.0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(v bool) *bool

Bool returns pointer to bool value.

func Byte

func Byte(v byte) *byte

Byte returns pointer to byte value.

func Complex64

func Complex64(v complex64) *complex64

Complex64 returns pointer to complex64 value.

func Complex128

func Complex128(v complex128) *complex128

Complex128 returns pointer to complex128 value.

func Duration added in v1.2.0

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

Duration returns pointer to time.Duration value.

func Float32

func Float32(v float32) *float32

Float32 returns pointer to float32 value.

func Float64

func Float64(v float64) *float64

Float64 returns pointer to float64 value.

func Int

func Int(v int) *int

Int returns pointer to int value.

func Int8

func Int8(v int8) *int8

Int8 returns pointer to int8 value.

func Int16

func Int16(v int16) *int16

Int16 returns pointer to int16 value.

func Int32

func Int32(v int32) *int32

Int32 returns pointer to int32 value.

func Int64

func Int64(v int64) *int64

Int64 returns pointer to int64 value.

func Rune

func Rune(v rune) *rune

Rune returns pointer to rune value.

func String

func String(v string) *string

String returns pointer to string value.

func Time added in v1.3.0

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

Time returns pointer to time.Time value.

func ToBool added in v1.1.0

func ToBool(v *bool) bool

ToBool returns the value of the bool pointer passed in or false if the pointer is nil.

func ToBoolDef added in v1.1.0

func ToBoolDef(v *bool, def bool) bool

ToBoolDef returns the value of the bool pointer passed in or default value if the pointer is nil.

func ToByte added in v1.1.0

func ToByte(v *byte) byte

ToByte returns the value of the byte pointer passed in or 0 if the pointer is nil.

func ToByteDef added in v1.1.0

func ToByteDef(v *byte, def byte) byte

ToByteDef returns the value of the byte pointer passed in or default value if the pointer is nil.

func ToComplex64 added in v1.1.0

func ToComplex64(v *complex64) complex64

ToComplex64 returns the value of the complex64 pointer passed in or 0 if the pointer is nil.

func ToComplex64Def added in v1.1.0

func ToComplex64Def(v *complex64, def complex64) complex64

ToComplex64Def returns the value of the complex64 pointer passed in or default value if the pointer is nil.

func ToComplex128 added in v1.1.0

func ToComplex128(v *complex128) complex128

ToComplex128 returns the value of the complex128 pointer passed in or 0 if the pointer is nil.

func ToComplex128Def added in v1.1.0

func ToComplex128Def(v *complex128, def complex128) complex128

ToComplex128Def returns the value of the complex128 pointer passed in or default value if the pointer is nil.

func ToDuration added in v1.2.0

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

ToDuration returns the value of the time.Duration pointer passed in or 0 if the pointer is nil.

func ToDurationDef added in v1.2.0

func ToDurationDef(v *time.Duration, def time.Duration) time.Duration

ToDurationDef returns the value of the time.Duration pointer passed in or default value if the pointer is nil.

func ToFloat32 added in v1.1.0

func ToFloat32(v *float32) float32

ToFloat32 returns the value of the float32 pointer passed in or 0 if the pointer is nil.

func ToFloat32Def added in v1.1.0

func ToFloat32Def(v *float32, def float32) float32

ToFloat32Def returns the value of the float32 pointer passed in or default value if the pointer is nil.

func ToFloat64 added in v1.1.0

func ToFloat64(v *float64) float64

ToFloat64 returns the value of the float64 pointer passed in or 0 if the pointer is nil.

func ToFloat64Def added in v1.1.0

func ToFloat64Def(v *float64, def float64) float64

ToFloat64Def returns the value of the float64 pointer passed in or default value if the pointer is nil.

func ToInt added in v1.1.0

func ToInt(v *int) int

ToInt returns the value of the int pointer passed in or int if the pointer is nil. ToInt returns the value of the int pointer passed in or 0 if the pointer is nil.

func ToInt8 added in v1.1.0

func ToInt8(v *int8) int8

ToInt8 returns the value of the int8 pointer passed in or 0 if the pointer is nil.

func ToInt8Def added in v1.1.0

func ToInt8Def(v *int8, def int8) int8

ToInt8Def returns the value of the int8 pointer passed in or default value if the pointer is nil.

func ToInt16 added in v1.1.0

func ToInt16(v *int16) int16

ToInt16 returns the value of the int16 pointer passed in or 0 if the pointer is nil.

func ToInt16Def added in v1.1.0

func ToInt16Def(v *int16, def int16) int16

ToInt16Def returns the value of the int16 pointer passed in or default value if the pointer is nil.

func ToInt32 added in v1.1.0

func ToInt32(v *int32) int32

ToInt32 returns the value of the int32 pointer passed in or 0 if the pointer is nil.

func ToInt32Def added in v1.1.0

func ToInt32Def(v *int32, def int32) int32

ToInt32Def returns the value of the int32 pointer passed in or default value if the pointer is nil.

func ToInt64 added in v1.1.0

func ToInt64(v *int64) int64

ToInt64 returns the value of the int64 pointer passed in or 0 if the pointer is nil.

func ToInt64Def added in v1.1.0

func ToInt64Def(v *int64, def int64) int64

ToInt64Def returns the value of the int64 pointer passed in or default value if the pointer is nil.

func ToIntDef added in v1.1.0

func ToIntDef(v *int, def int) int

ToIntDef returns the value of the int pointer passed in or default value if the pointer is nil.

func ToRune added in v1.1.0

func ToRune(v *rune) rune

ToRune returns the value of the rune pointer passed in or 0 if the pointer is nil.

func ToRuneDef added in v1.1.0

func ToRuneDef(v *rune, def rune) rune

ToRuneDef returns the value of the rune pointer passed in or default value if the pointer is nil.

func ToString added in v1.1.0

func ToString(v *string) string

ToString returns the value of the string pointer passed in or empty string if the pointer is nil.

func ToStringDef added in v1.1.0

func ToStringDef(v *string, def string) string

ToStringDef returns the value of the string pointer passed in or default value if the pointer is nil.

func ToTime added in v1.3.0

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

ToTime returns the value of the time.Time pointer passed in or Time{} if the pointer is nil.

func ToTimeDef added in v1.3.0

func ToTimeDef(v *time.Time, def time.Time) time.Time

ToTimeDef returns the value of the time.Time pointer passed in or default value if the pointer is nil.

func ToUInt added in v1.1.0

func ToUInt(v *uint) uint

ToUInt returns the value of the uint pointer passed in or 0 if the pointer is nil.

func ToUInt8 added in v1.1.0

func ToUInt8(v *uint8) uint8

ToUInt8 returns the value of the uint8 pointer passed in or 0 if the pointer is nil.

func ToUInt8Def added in v1.1.0

func ToUInt8Def(v *uint8, def uint8) uint8

ToUInt8Def returns the value of the uint8 pointer passed in or default value if the pointer is nil.

func ToUInt16 added in v1.1.0

func ToUInt16(v *uint16) uint16

ToUInt16 returns the value of the uint16 pointer passed in or 0 if the pointer is nil.

func ToUInt16Def added in v1.1.0

func ToUInt16Def(v *uint16, def uint16) uint16

ToUInt16Def returns the value of the uint16 pointer passed in or default value if the pointer is nil.

func ToUInt32 added in v1.1.0

func ToUInt32(v *uint32) uint32

ToUInt32 returns the value of the uint32 pointer passed in or 0 if the pointer is nil.

func ToUInt32Def added in v1.1.0

func ToUInt32Def(v *uint32, def uint32) uint32

ToUInt32Def returns the value of the uint32 pointer passed in or default value if the pointer is nil.

func ToUInt64 added in v1.1.0

func ToUInt64(v *uint64) uint64

ToUInt64 returns the value of the uint64 pointer passed in or 0 if the pointer is nil.

func ToUInt64Def added in v1.1.0

func ToUInt64Def(v *uint64, def uint64) uint64

ToUInt64Def returns the value of the uint64 pointer passed in or default value if the pointer is nil.

func ToUIntDef added in v1.1.0

func ToUIntDef(v *uint, def uint) uint

ToUIntDef returns the value of the uint pointer passed in or default value if the pointer is nil.

func UInt

func UInt(v uint) *uint

UInt returns pointer to uint value.

func UInt8

func UInt8(v uint8) *uint8

UInt8 returns pointer to uint8 value.

func UInt16

func UInt16(v uint16) *uint16

UInt16 returns pointer to uint16 value.

func UInt32

func UInt32(v uint32) *uint32

UInt32 returns pointer to uint32 value.

func UInt64

func UInt64(v uint64) *uint64

UInt64 returns pointer to uint64 value.

Types

This section is empty.

Jump to

Keyboard shortcuts

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