lazy

package
v1.0.21 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2022 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Lazy

type Lazy[T any] interface {
	// Get when first called, will run the initialization function and cache the output. Returns cached output on
	// subsequent runs.
	Get() T
}

Lazy is a caching concurrency-safe lazy initializer

func NewLazy

func NewLazy[T any](initializer func() T) Lazy[T]

NewLazy given an initialization function return a Lazy that wraps it

type LazyE

type LazyE[T any] interface {
	// Get when first called, will run the initialization function and cache the output. Returns cached output on
	// subsequent runs.
	Get() (T, error)
}

LazyE is a caching, concurrent-safe lazy initializer, for initializations that might produce an error

func NewLazyE

func NewLazyE[T any](initializer func() (T, error)) LazyE[T]

NewLazyE given an initialization function return a LazyE that wraps it

Jump to

Keyboard shortcuts

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