nullable

package
v0.20250114.1063937 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2025 License: MPL-2.0 Imports: 2 Imported by: 406

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Type

type Type[T comparable] map[bool]T

func NoZero

func NoZero[T comparable](t T) Type[T]

NoZero returns a new Type[T], setting its type and value, whilst also nulling the value if it was set to its zero value. This ensures that zero values are sent as null.

func Value

func Value[T comparable](t T) Type[T]

Value returns a new Type[T], setting its type and value to the provided value

func (Type[T]) Get

func (t Type[T]) Get() *T

Get retrieves the underlying value, if present, and returns nil if the value is null

func (Type[T]) GetOrZero

func (t Type[T]) GetOrZero() T

GetOrZero retrieves the underlying value, if present, and returns the zero value if null

func (Type[T]) IsNull

func (t Type[T]) IsNull() bool

IsNull indicates whether the value was set to `null`

func (Type[T]) IsSet

func (t Type[T]) IsSet() bool

IsSet indicates whether a value is set

func (Type[T]) MarshalJSON

func (t Type[T]) MarshalJSON() ([]byte, error)

func (*Type[T]) Set

func (t *Type[T]) Set(value T)

Set sets the underlying value to a given value

func (*Type[T]) SetNoZero

func (t *Type[T]) SetNoZero(value T)

SetNoZero sets the underlying value to a given value, whilst also nulling the value if it was set to its zero value. This ensures that zero values are sent as null.

func (*Type[T]) SetNull

func (t *Type[T]) SetNull()

SetNull clears the value and ensures a value of `null`

func (*Type[T]) SetUnspecified

func (t *Type[T]) SetUnspecified()

SetUnspecified clears the value

func (*Type[T]) UnmarshalJSON

func (t *Type[T]) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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