lazy

package
v0.0.0-...-157f73e Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package lazy is a package to expose lazily computed values. The concepts and code are heavily influenced by https://cs.opensource.google/go/go/+/go1.19:src/sync/once.go.

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 returns the value, computing it if necessary.
	Get() (T, error)
}

Lazy represents a value whose computation is deferred until the first access

func New

func New[T any](f func() (T, error)) Lazy[T]

New returns a new lazily computed value. The value is guaranteed to only be computed a single time.

func NewWithRetry

func NewWithRetry[T any](f func() (T, error)) Lazy[T]

NewWithRetry returns a new lazily computed value. The value will be computed on each call until a non-nil error is returned.

Jump to

Keyboard shortcuts

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