Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Optional

type Optional optional

    Optional wraps a value that may or may not be nil. If a value is present, it may be unwrapped to expose the underlying value.

    func Empty

    func Empty() Optional

      Empty returns an empty optional.

      func Of

      func Of(value T) Optional

        Of wraps the value in an optional.

        func OfOptionalPtr

        func OfOptionalPtr(ptr *T) Optional

        func (Optional) Else

        func (o Optional) Else(elseValue T) (value T)

          Else returns the value wrapped by this optional, or the value passed in if there is no value wrapped by this optional.

          func (Optional) ElseFunc

          func (o Optional) ElseFunc(f func() T) (value T)

          func (Optional) ElseZero

          func (o Optional) ElseZero() (value T)

            ElseZero returns the value wrapped by this optional, or the zero value of the type wrapped if there is no value wrapped by this optional.

            func (Optional) Get

            func (o Optional) Get() (value T, ok bool)

              Get returns the value wrapped by this optional, and an ok signal for whether a value was wrapped.

              func (Optional) If

              func (o Optional) If(f func(value T))

                If calls the function if there is a value wrapped by this optional.

                func (Optional) IsPresent

                func (o Optional) IsPresent() bool

                  IsPresent returns true if there is a value wrapped by this optional.

                  func (Optional) MarshalJSON

                  func (o Optional) MarshalJSON() (data []byte, err error)

                    MarshalJSON marshals the value being wrapped to JSON. If there is no vale being wrapped, the zero value of its type is marshaled.

                    func (Optional) MarshalXML

                    func (o Optional) MarshalXML(e *xml.Encoder, start xml.StartElement) error

                      MarshalXML marshals the value being wrapped to XML. If there is no vale being wrapped, the zero value of its type is marshaled.

                      func (Optional) String

                      func (o Optional) String() string

                        String returns the string representation of the wrapped value, or the string representation of the zero value of the type wrapped if there is no value wrapped by this optional.

                        func (*Optional) UnmarshalJSON

                        func (o *Optional) UnmarshalJSON(data []byte) error

                          UnmarshalJSON unmarshals the JSON into a value wrapped by this optional.

                          func (*Optional) UnmarshalXML

                          func (o *Optional) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

                            UnmarshalXML unmarshals the XML into a value wrapped by this optional.

                            type T

                            type T string

                            Source Files