optional

package module
v0.51.0-rc.6 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2024 License: Apache-2.0 Imports: 0 Imported by: 10

Documentation

Overview

Package optional has optional types and functions used by Agent.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

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

Option represents an optional type. By default, no value is set and a call to Get() returns (T{}, false)

func MapOption

func MapOption[T1 any, T2 any](optional Option[T1], fct func(T1) T2) Option[T2]

MapOption returns fct(value) if a value is set, otherwise it returns NewNoneOption[T2]().

func NewNoneOption

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

NewNoneOption creates a new instance of Option[T] without any value set.

func NewOption

func NewOption[T any](value T) Option[T]

NewOption creates a new instance of Option[T] with a value set. A call to Get() will returns (value, true)

func (*Option[T]) Get

func (o *Option[T]) Get() (T, bool)

Get returns the value and true if a value is set, otherwise it returns (undefined, false).

func (*Option[T]) IsSet

func (o *Option[T]) IsSet() bool

IsSet returns true if a value is set.

func (*Option[T]) Reset

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

Reset removes the value set.

func (*Option[T]) Set

func (o *Option[T]) Set(value T)

Set sets a new value.

func (*Option[T]) UnmarshalYAML

func (o *Option[T]) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML unmarshals an Option[T] from YAML

Jump to

Keyboard shortcuts

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