nullable

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Field

type Field[T any] struct {
	// contains filtered or unexported fields
}

Field is a wrapper for nullable fields to distinguish zero values from null or omitted fields.

func Bool

func Bool(value bool) *Field[bool]

Bool is a nullable field helper for constructing nullable bools with a value.

func Float

func Float(value float32) *Field[float32]

Float is a nullable field helper for constructing nullable floats with a value.

func Float64

func Float64(value float64) *Field[float64]

Float64 is a nullable field helper for constructing nullable float64 values.

func Int

func Int(value int) *Field[int]

Int is a nullable field helper for constructing nullable integers with a value.

func Int32

func Int32(value int32) *Field[int32]

Int32 is a nullable field helper for constructing nullable int32 values.

func Int64

func Int64(value int64) *Field[int64]

Int64 is a nullable field helper for constructing nullable int64 values.

func Null

func Null[T any]() *Field[T]

Null is a nullable field helper for constructing a generic null fields.

func String

func String(value string) *Field[string]

String is a nullable field helper for constructing nullable strings with a value.

func Value

func Value[T any](value T) *Field[T]

Value is a nullable field helper for constructing a generic nullable field with a value.

func (Field[T]) MarshalJSON

func (f Field[T]) MarshalJSON() ([]byte, error)

func (*Field[T]) Null

func (f *Field[T]) Null() bool

Null returns true if the field is present and has explicit null value.

func (Field[T]) String

func (f Field[T]) String() string

func (*Field[T]) UnmarshalJSON

func (f *Field[T]) UnmarshalJSON(data []byte) error

func (*Field[T]) Value

func (f *Field[T]) Value() *T

Value returns the value of the nullable field if the field is present and has value set. Using Value you loose information about nullability, i.e. it is no longer possible to distinguish between the field not being present or the field being present as null.

Jump to

Keyboard shortcuts

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