pointers

package
v1.32.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: MIT Imports: 1 Imported by: 0

README

Pointers

  • DefaultIfNil: Returns a default value if the pointer is nil.
  • NullableBool: Returns the value of a boolean pointer or false if nil.
  • NullableTime: Returns the value of a time pointer or a zero time value if nil.
  • NullableInt: Returns the value of an integer pointer or zero if nil.
  • NullableString: Returns the value of a string pointer or an empty string if nil.

Examples:

For examples of each function, please checkout EXAMPLES.md


Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultIfNil

func DefaultIfNil[T any](ptr *T, defaultVal T) T

DefaultIfNil returns the value of the pointer if it is not nil, or the default value if the pointer is nil

func NullableBool

func NullableBool(b *bool) bool

NullableBool returns the value of the bool pointer or false if the pointer is nil

func NullableByteSlice

func NullableByteSlice(b *[]byte) []byte

NullableByteSlice returns the dereferenced value of *[]byte if not nil, or an empty byte slice otherwise.

func NullableComplex64

func NullableComplex64(c *complex64) complex64

NullableComplex64 returns the dereferenced value of *complex64 if not nil, or 0+0i otherwise.

func NullableComplex128

func NullableComplex128(c *complex128) complex128

NullableComplex128 returns the dereferenced value of *complex128 if not nil, or 0+0i otherwise.

func NullableFloat32

func NullableFloat32(f *float32) float32

NullableFloat32 returns the dereferenced value of *float32 if not nil, or 0.0 otherwise.

func NullableFloat64

func NullableFloat64(f *float64) float64

NullableFloat64 returns the dereferenced value of *float64 if not nil, or 0.0 otherwise.

func NullableInt

func NullableInt(i *int) int

NullableInt returns the dereferenced value of the int pointer or 0 if the pointer is nil

func NullableInt8

func NullableInt8(i *int8) int8

NullableInt8 returns the dereferenced value of *int8 if not nil, or 0 otherwise.

func NullableInt16

func NullableInt16(i *int16) int16

NullableInt16 returns the dereferenced value of *int16 if not nil, or 0 otherwise.

func NullableInt32

func NullableInt32(i *int32) int32

NullableInt32 returns the dereferenced value of *int32 if not nil, or 0 otherwise.

func NullableInt64

func NullableInt64(i *int64) int64

NullableInt64 returns the dereferenced value of *int64 if not nil, or 0 otherwise.

func NullableString

func NullableString(s *string) string

NullableString returns the value of the string pointer or an empty string if the pointer is nil

func NullableTime

func NullableTime(t *time.Time) time.Time

NullableTime returns the dereferenced value of *time.Time if not nil, or a zero time.Time otherwise.

func NullableUint

func NullableUint(i *uint) uint

NullableUint returns the dereferenced value of *uint if not nil, or 0 otherwise.

func NullableUint8

func NullableUint8(i *uint8) uint8

NullableUint8 returns the dereferenced value of *uint8 if not nil, or 0 otherwise.

func NullableUint16

func NullableUint16(i *uint16) uint16

NullableUint16 returns the dereferenced value of *uint16 if not nil, or 0 otherwise.

func NullableUint32

func NullableUint32(i *uint32) uint32

NullableUint32 returns the dereferenced value of *uint32 if not nil, or 0 otherwise.

func NullableUint64

func NullableUint64(i *uint64) uint64

NullableUint64 returns the dereferenced value of *uint64 if not nil, or 0 otherwise.

Types

This section is empty.

Jump to

Keyboard shortcuts

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