lazy

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLazyValue

func GetLazyValue(x reflect.Value) reflect.Value

GetLazyValue returns the return value of x.GetLazyValue() when x implements that method, otherwise return x directly

Types

type ImmediateString added in v0.10.0

type ImmediateString string

ImmediateString implements lazy.Interface for plain string value

func (ImmediateString) GetLazyValue added in v0.10.0

func (s ImmediateString) GetLazyValue() string

type Interface added in v0.11.0

type Interface[T any] interface {
	GetLazyValue() T
}

Interface defines methods required for a lazy value

type Value

type Value[T any] struct {

	// Create is the function to create the lazy value
	Create func() T
	// contains filtered or unexported fields
}

Value holds a lazily initialized value, the Create func is used to initialize the value and is called when GetLazyValue() called for the first time

func (*Value[T]) GetLazyValue added in v0.12.0

func (v *Value[T]) GetLazyValue() T

Jump to

Keyboard shortcuts

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