Documentation ¶
Overview ¶
Package lazyget provides a simple way to create thread-safe, type-safe getter functions to lazily initialize, cache, and return a value of a given type. It uses a sync.Once to ensure that the initialization function is only called once, even in concurrent environments. All subsequent calls will return the cached value.
Usage:
var GetResource = lazyget.New(func() *Resource { // do some expensive initialization here return &Resource{} }) r := GetResource() // r is of type *Resource
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.