Documentation
¶
Overview ¶
Package types contains a collection of types and functions that are useful in Go.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Option ¶
type Option[T any] struct { // contains filtered or unexported fields }
An Option type is a type that can contain a value or nothing.
func (Option[T]) Default ¶
func (o Option[T]) Default(value T) T
Default returns the Option value if it is present, otherwise it returns the value passed.
func (Option[T]) Get ¶
Get returns the value and a boolean indicating if the Option contains a value.
func (Option[T]) MarshalJSON ¶
func (*Option[T]) UnmarshalJSON ¶
type Result ¶
type Result[T any] struct { // contains filtered or unexported fields }
A Result type is a type that can contain an error or a value.
func Outcome ¶
Outcome returns a Result that contains a value or an error.
It can be used to convert a function that returns a value and an error into a Result.
func (Result[T]) Default ¶
func (r Result[T]) Default(value T) T
Default returns the Result value if it is present, otherwise it returns the value passed.
func (Result[T]) MarshalJSON ¶
func (*Result[T]) UnmarshalJSON ¶
Click to show internal directories.
Click to hide internal directories.