ptr

package module
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2022 License: Apache-2.0 Imports: 2 Imported by: 5

README

ptr

codecov go report card test status Apache-2.0 license Go.Dev reference

get pointer of value

Install

go get github.com/chyroc/go-ptr

Usage

godoc: https://pkg.go.dev/github.com/chyroc/go-ptr

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(s bool) *bool

Bool returns the pointer of boolean value

func BoolNoNonePtr added in v1.2.0

func BoolNoNonePtr(s bool) *bool

BoolNoNonePtr returns the pointer of bool value, if the value is zero-value, it returns nil

func Byte

func Byte(s byte) *byte

Byte returns the pointer of byte value

func ByteNoNonePtr added in v1.2.0

func ByteNoNonePtr(s byte) *byte

ByteNoNonePtr returns the pointer of byte value, if the value is zero-value, it returns nil

func Complex128

func Complex128(s complex128) *complex128

Complex128 returns the pointer of complex128 value

func Complex128NoNonePtr added in v1.2.0

func Complex128NoNonePtr(s complex128) *complex128

Complex128NoNonePtr returns the pointer of complex128 value, if the value is zero-value, it returns nil

func Complex64

func Complex64(s complex64) *complex64

Complex64 returns the pointer of complex64 value

func Complex64NoNonePtr added in v1.2.0

func Complex64NoNonePtr(s complex64) *complex64

Complex64NoNonePtr returns the pointer of complex64 value, if the value is zero-value, it returns nil

func Duration added in v1.1.0

func Duration(s time.Duration) *time.Duration

Duration returns the pointer of time.Duration value

func DurationNoNonePtr added in v1.2.0

func DurationNoNonePtr(s time.Duration) *time.Duration

DurationNoNonePtr returns the pointer of time.Duration value, if the value is zero-value, it returns nil

func Error

func Error(s error) *error

Error returns the pointer of error value

func ErrorNoNonePtr added in v1.2.0

func ErrorNoNonePtr(s error) *error

ErrorNoNonePtr returns the pointer of error value, if the value is zero-value, it returns nil

func Float32

func Float32(s float32) *float32

Float32 returns the pointer of float32 value

func Float32NoNonePtr added in v1.2.0

func Float32NoNonePtr(s float32) *float32

Float32NoNonePtr returns the pointer of float32 value, if the value is zero-value, it returns nil

func Float64

func Float64(s float64) *float64

Float64 returns the pointer of float64 value

func Float64NoNonePtr added in v1.2.0

func Float64NoNonePtr(s float64) *float64

Float64NoNonePtr returns the pointer of float64 value, if the value is zero-value, it returns nil

func Int

func Int(s int) *int

Int returns the pointer of int value

func Int16

func Int16(s int16) *int16

Int16 returns the pointer of int16 value

func Int16NoNonePtr added in v1.2.0

func Int16NoNonePtr(s int16) *int16

Int16NoNonePtr returns the pointer of int16 value, if the value is zero-value, it returns nil

func Int32

func Int32(s int32) *int32

Int32 returns the pointer of int32 value

func Int32NoNonePtr added in v1.2.0

func Int32NoNonePtr(s int32) *int32

Int32NoNonePtr returns the pointer of int32 value, if the value is zero-value, it returns nil

func Int64

func Int64(s int64) *int64

Int64 returns the pointer of int64 value

func Int64NoNonePtr added in v1.2.0

func Int64NoNonePtr(s int64) *int64

Int64NoNonePtr returns the pointer of int64 value, if the value is zero-value, it returns nil

func Int8

func Int8(s int8) *int8

Int8 returns the pointer of int8 value

func Int8NoNonePtr added in v1.2.0

func Int8NoNonePtr(s int8) *int8

Int8NoNonePtr returns the pointer of int8 value, if the value is zero-value, it returns nil

func IntNoNonePtr added in v1.2.0

func IntNoNonePtr(s int) *int

IntNoNonePtr returns the pointer of int value, if the value is zero-value, it returns nil

func NoNonePtr added in v1.7.0

func NoNonePtr[T comparable](s T) *T

NoNonePtr returns the pointer of int value, if the value is zero-value, it returns nil.

func PointerInt64ToTime added in v1.3.0

func PointerInt64ToTime(i *int64) *time.Time

PointerInt64ToTime converts a pointer of type *int64 to a time.Time.

func PointerTimeToInt64 added in v1.5.0

func PointerTimeToInt64(i *time.Time) *int64

PointerTimeToInt64 converts a pointer of type *time.Time to a int64.

func Ptr added in v1.6.0

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

func ReflectType added in v1.4.0

func ReflectType(s reflect.Type) *reflect.Type

ReflectType returns the pointer of reflect.Type value

func ReflectValue added in v1.4.0

func ReflectValue(s reflect.Value) *reflect.Value

ReflectValue returns the pointer of reflect.Value value

func Rune

func Rune(s rune) *rune

Rune returns the pointer of rune value

func RuneNoNonePtr added in v1.2.0

func RuneNoNonePtr(s rune) *rune

RuneNoNonePtr returns the pointer of rune value, if the value is zero-value, it returns nil

func String

func String(s string) *string

String returns the pointer of string value

func StringNoNonePtr added in v1.2.0

func StringNoNonePtr(s string) *string

StringNoNonePtr returns the pointer of string value, if the value is zero-value, it returns nil

func Time added in v1.1.0

func Time(s time.Time) *time.Time

Time returns the pointer of time.Time value

func TimeNoNonePtr added in v1.2.0

func TimeNoNonePtr(s time.Time) *time.Time

TimeNoNonePtr returns the pointer of time.Time value, if the value is zero-value, it returns nil

func UInt

func UInt(s uint) *uint

UInt returns the pointer of uint value

func UInt16

func UInt16(s uint16) *uint16

UInt16 returns the pointer of uint16 value

func UInt16NoNonePtr added in v1.2.0

func UInt16NoNonePtr(s uint16) *uint16

UInt16NoNonePtr returns the pointer of uint16 value, if the value is zero-value, it returns nil

func UInt32

func UInt32(s uint32) *uint32

UInt32 returns the pointer of uint32 value

func UInt32NoNonePtr added in v1.2.0

func UInt32NoNonePtr(s uint32) *uint32

UInt32NoNonePtr returns the pointer of uint32 value, if the value is zero-value, it returns nil

func UInt64

func UInt64(s uint64) *uint64

UInt64 returns the pointer of uint64 value

func UInt64NoNonePtr added in v1.2.0

func UInt64NoNonePtr(s uint64) *uint64

UInt64NoNonePtr returns the pointer of uint64 value, if the value is zero-value, it returns nil

func UInt8

func UInt8(s uint8) *uint8

UInt8 returns the pointer of uint8 value

func UInt8NoNonePtr added in v1.2.0

func UInt8NoNonePtr(s uint8) *uint8

UInt8NoNonePtr returns the pointer of uint8 value, if the value is zero-value, it returns nil

func UIntNoNonePtr added in v1.2.0

func UIntNoNonePtr(s uint) *uint

UIntNoNonePtr returns the pointer of uint value, if the value is zero-value, it returns nil

func UIntptr

func UIntptr(s uintptr) *uintptr

UIntptr returns the pointer of uintptr value

func UIntptrNoNonePtr added in v1.2.0

func UIntptrNoNonePtr(s uintptr) *uintptr

UIntptrNoNonePtr returns the pointer of uintptr value, if the value is zero-value, it returns nil

func Value added in v1.7.0

func Value[T any](s *T) T

Value returns the value pointed to by the pointer

func ValueBool added in v1.1.0

func ValueBool(s *bool) bool

ValueBool returns the value pointed to by the pointer

func ValueBoolWithDefault added in v1.1.0

func ValueBoolWithDefault(s *bool, defaultValue bool) bool

func ValueByte added in v1.1.0

func ValueByte(s *byte) byte

ValueByte returns the value pointed to by the pointer

func ValueByteWithDefault added in v1.1.0

func ValueByteWithDefault(s *byte, defaultValue byte) byte

func ValueComplex128 added in v1.1.0

func ValueComplex128(s *complex128) complex128

ValueComplex128 returns the value pointed to by the pointer

func ValueComplex128WithDefault added in v1.1.0

func ValueComplex128WithDefault(s *complex128, defaultValue complex128) complex128

func ValueComplex64 added in v1.1.0

func ValueComplex64(s *complex64) complex64

ValueComplex64 returns the value pointed to by the pointer

func ValueComplex64WithDefault added in v1.1.0

func ValueComplex64WithDefault(s *complex64, defaultValue complex64) complex64

func ValueDuration added in v1.3.1

func ValueDuration(s *time.Duration) time.Duration

ValueDuration returns the value pointed to by the pointer

func ValueDurationWithDefault added in v1.3.1

func ValueDurationWithDefault(s *time.Duration, defaultValue time.Duration) time.Duration

func ValueError added in v1.1.0

func ValueError(s *error) error

ValueError returns the value pointed to by the pointer

func ValueErrorWithDefault added in v1.1.0

func ValueErrorWithDefault(s *error, defaultValue error) error

func ValueFloat32 added in v1.1.0

func ValueFloat32(s *float32) float32

ValueFloat32 returns the value pointed to by the pointer

func ValueFloat32WithDefault added in v1.1.0

func ValueFloat32WithDefault(s *float32, defaultValue float32) float32

func ValueFloat64 added in v1.1.0

func ValueFloat64(s *float64) float64

ValueFloat64 returns the value pointed to by the pointer

func ValueFloat64WithDefault added in v1.1.0

func ValueFloat64WithDefault(s *float64, defaultValue float64) float64

func ValueInt added in v1.1.0

func ValueInt(s *int) int

ValueInt returns the value pointed to by the pointer

func ValueInt16 added in v1.1.0

func ValueInt16(s *int16) int16

ValueInt16 returns the value pointed to by the pointer

func ValueInt16WithDefault added in v1.1.0

func ValueInt16WithDefault(s *int16, defaultValue int16) int16

func ValueInt32 added in v1.1.0

func ValueInt32(s *int32) int32

ValueInt32 returns the value pointed to by the pointer

func ValueInt32WithDefault added in v1.1.0

func ValueInt32WithDefault(s *int32, defaultValue int32) int32

func ValueInt64 added in v1.1.0

func ValueInt64(s *int64) int64

ValueInt64 returns the value pointed to by the pointer

func ValueInt64WithDefault added in v1.1.0

func ValueInt64WithDefault(s *int64, defaultValue int64) int64

func ValueInt8 added in v1.1.0

func ValueInt8(s *int8) int8

ValueInt8 returns the value pointed to by the pointer

func ValueInt8WithDefault added in v1.1.0

func ValueInt8WithDefault(s *int8, defaultValue int8) int8

func ValueIntWithDefault added in v1.1.0

func ValueIntWithDefault(s *int, defaultValue int) int

func ValueRune added in v1.1.0

func ValueRune(s *rune) rune

ValueRune returns the value pointed to by the pointer

func ValueRuneWithDefault added in v1.1.0

func ValueRuneWithDefault(s *rune, defaultValue rune) rune

func ValueString added in v1.1.0

func ValueString(s *string) string

ValueString returns the value pointed to by the pointer

func ValueStringWithDefault added in v1.1.0

func ValueStringWithDefault(s *string, defaultValue string) string

func ValueTime added in v1.3.1

func ValueTime(s *time.Time) time.Time

ValueTime returns the value pointed to by the pointer

func ValueTimeWithDefault added in v1.3.1

func ValueTimeWithDefault(s *time.Time, defaultValue time.Time) time.Time

func ValueUInt added in v1.1.0

func ValueUInt(s *uint) uint

ValueUInt returns the value pointed to by the pointer

func ValueUInt16 added in v1.1.0

func ValueUInt16(s *uint16) uint16

ValueUInt16 returns the value pointed to by the pointer

func ValueUInt16WithDefault added in v1.1.0

func ValueUInt16WithDefault(s *uint16, defaultValue uint16) uint16

func ValueUInt32 added in v1.1.0

func ValueUInt32(s *uint32) uint32

ValueUInt32 returns the value pointed to by the pointer

func ValueUInt32WithDefault added in v1.1.0

func ValueUInt32WithDefault(s *uint32, defaultValue uint32) uint32

func ValueUInt64 added in v1.1.0

func ValueUInt64(s *uint64) uint64

ValueUInt64 returns the value pointed to by the pointer

func ValueUInt64WithDefault added in v1.1.0

func ValueUInt64WithDefault(s *uint64, defaultValue uint64) uint64

func ValueUInt8 added in v1.1.0

func ValueUInt8(s *uint8) uint8

ValueUInt8 returns the value pointed to by the pointer

func ValueUInt8WithDefault added in v1.1.0

func ValueUInt8WithDefault(s *uint8, defaultValue uint8) uint8

func ValueUIntWithDefault added in v1.1.0

func ValueUIntWithDefault(s *uint, defaultValue uint) uint

func ValueUIntptr added in v1.1.0

func ValueUIntptr(s *uintptr) uintptr

ValueUIntptr returns the value pointed to by the pointer

func ValueUIntptrWithDefault added in v1.1.0

func ValueUIntptrWithDefault(s *uintptr, defaultValue uintptr) uintptr

func ValueWithDefault added in v1.6.0

func ValueWithDefault[T any](s *T, defaultValue T) T

Types

This section is empty.

Jump to

Keyboard shortcuts

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