optional

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: MIT Imports: 3 Imported by: 0

README

optional

generic optional type for golang

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExcractValue added in v1.1.0

func ExcractValue(obj any) (any, bool)

ExcractValue return value or nil and bool if object was an Optional it should only be used if you already have to deal with interface{} values and expect an Option type within it.

func ToPtr

func ToPtr[T any](val T) *T

Depricated

Types

type Option

type Option[T any] []T

func FromNonDefault

func FromNonDefault[T comparable](v T) Option[T]

func FromPtr

func FromPtr[T any](v *T) Option[T]

func None

func None[T any]() Option[T]

func Some

func Some[T any](v T) Option[T]

func (Option[T]) Has

func (o Option[T]) Has() bool

func (Option[T]) MarshalJSON

func (o Option[T]) MarshalJSON() ([]byte, error)

func (Option[T]) MarshalYAML

func (o Option[T]) MarshalYAML() (interface{}, error)

func (Option[T]) ToPtr added in v1.1.0

func (o Option[T]) ToPtr() *T

func (*Option[T]) UnmarshalJSON

func (o *Option[T]) UnmarshalJSON(data []byte) error

func (*Option[T]) UnmarshalYAML

func (o *Option[T]) UnmarshalYAML(value *yaml.Node) error

func (Option[T]) Value

func (o Option[T]) Value() T

func (Option[T]) ValueOrDefault

func (o Option[T]) ValueOrDefault(v T) T

Jump to

Keyboard shortcuts

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