Documentation ¶
Overview ¶
once contains helpers for constructing type-safe, concurrency-safe values that are only ever initialized once, and can potentially return an error.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Map ¶
type Map[K comparable, V any] interface { // Set initializes the key K at most one time, and returns the result. Set(K, func() (*V, error)) (*V, error) // Get returns the initialization result associated with the key K. // If K has not yet been initialized, the result will be (<nil>, <nil>). Get(K) (*V, error) }
Map is a type-safe and concurrency-safe implementation of a map where each entry is initialized a single time.
type Var ¶
type Var[T any] interface { // Set initializes the var at most one time, and returns the result. // If K has not yet been initialized, the result will be (<nil>, <nil>). Set(func() (*T, error)) (*T, error) // Get returns the initialized result. If the var has not yet been // initialized, the result will be (<nil>, <nil>) Get() (*T, error) }
Var is a type-safe and concurrency-safe wrapper for a value that is initialized a single time.
Click to show internal directories.
Click to hide internal directories.