optional

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2025 License: MIT Imports: 1 Imported by: 0

README

optional-go

A library that provides Go Generics friendly "optional" features.

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
}

func NewField

func NewField[T any](v T) Field[T]

func NewFieldFromPtr

func NewFieldFromPtr[T any](v *T) Field[T]

func (*Field[T]) Get

func (i *Field[T]) Get() (T, bool)

func (*Field[T]) If

func (i *Field[T]) If(fn func(T))

func (*Field[T]) MarshalJSON

func (i *Field[T]) MarshalJSON() ([]byte, error)

func (*Field[T]) MustGet

func (i *Field[T]) MustGet() T

func (*Field[T]) OrElse

func (i *Field[T]) OrElse(v T) T

func (*Field[T]) Present

func (i *Field[T]) Present() bool

func (*Field[T]) Set

func (i *Field[T]) Set(v T)

func (*Field[T]) ToPtr

func (i *Field[T]) ToPtr() *T

func (*Field[T]) UnmarshalJSON

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

Jump to

Keyboard shortcuts

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