Documentation ¶
Index ¶
- type Type
- func (t Type[T]) Get() *T
- func (t Type[T]) GetOrZero() T
- func (t Type[T]) IsNull() bool
- func (t Type[T]) IsSet() bool
- func (t Type[T]) MarshalJSON() ([]byte, error)
- func (t *Type[T]) Set(value T)
- func (t *Type[T]) SetNoZero(value T)
- func (t *Type[T]) SetNull()
- func (t *Type[T]) SetUnspecified()
- func (t *Type[T]) UnmarshalJSON(data []byte) error
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]) MarshalJSON ¶
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`