Documentation
¶
Index ¶
- type Value
- func (o *Value[T]) Get() (ok bool, value T)
- func (o *Value[T]) GetOr(value T) T
- func (o *Value[T]) HasValue() bool
- func (o *Value[T]) IsNil() bool
- func (o Value[T]) MarshalJSON() ([]byte, error)
- func (o *Value[T]) MustGet() (value T)
- func (o *Value[T]) Scan(src any) error
- func (o *Value[T]) Set(value T)
- func (o *Value[T]) SetNil()
- func (o *Value[T]) UnmarshalJSON(data []byte) error
- func (o *Value[T]) Value() (driver.Value, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Value ¶
type Value[T any] struct { // contains filtered or unexported fields }
Value wraps an optional value of type T
func (*Value[T]) Get ¶
Get returns true if optional value is non-nil, along with the underlying value
func (*Value[T]) GetOr ¶
func (o *Value[T]) GetOr(value T) T
GetOr returns the underlying non-nil value or the provided fallback value
func (Value[T]) MarshalJSON ¶
MarshalJSON implements json.Marshaler interface
func (*Value[T]) MustGet ¶
func (o *Value[T]) MustGet() (value T)
MustGet returns the underlying value or PANICS if value is nil
func (*Value[T]) Set ¶
func (o *Value[T]) Set(value T)
Set sets the underlying optional value to the provided non-nil value
func (*Value[T]) SetNil ¶
func (o *Value[T]) SetNil()
SetNil sets the underlying optional value to nil
func (*Value[T]) UnmarshalJSON ¶
MarshalJSON implements json.Unmarshaler interface
Click to show internal directories.
Click to hide internal directories.