paramutil

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddrIfPresent

func AddrIfPresent[T comparable](v param.Opt[T]) *T

func IsNullPtr added in v0.4.0

func IsNullPtr[T any](ptr *T) bool

IsNullPtr returns true if the pointer was created by NullPtr.

func IsNullSlice added in v0.4.0

func IsNullSlice[T any](slice []T) bool

IsNullSlice returns true if the slice was created by NullSlice.

func NullPtr added in v0.4.0

func NullPtr[T any]() *T

NullPtr returns a pointer to the zero value of the type T. When used with [MarshalObject] or [MarshalUnion], it will be marshaled as null.

It is unspecified behavior to mutate the value pointed to by the returned pointer.

func NullSlice added in v0.4.0

func NullSlice[T any]() []T

NullSlice returns a non-nil slice with a length of 0. When used with [MarshalObject] or [MarshalUnion], it will be marshaled as null.

It is undefined behavior to mutate the slice returned by NullSlice.

func ToOpt added in v0.2.0

func ToOpt[T comparable](v T, meta respjson.Field) param.Opt[T]

func Valid added in v0.4.0

func Valid(v param.ParamStruct) bool

Checks if the value is not omitted and not null

func VariantFromUnion

func VariantFromUnion(u reflect.Value) (any, error)

VariantFromUnion can be used to extract the present variant from a param union type. A param union type is a struct with an embedded field of [APIUnion].

Types

This section is empty.

Jump to

Keyboard shortcuts

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