Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrTypeMismatch = errors.New("the requested type does not match the singleton type")
Functions ¶
func Get ¶
Get returns a previously created value for the singleton, else the default value for T. Returns ErrTypeMismatch if the requested type does not match a type the existing singleton type. This function is threadsafe.
func GetOrDo ¶
GetOrDo will create and store a value in the Singleton, if one doesn't already exist, by calling the fn, else it will return the existing value. If the fn returns an error, that error will be returned and no value will be stored in the singleton. If the requested type does not match a type the existing singleton type, ErrTypeMismatch is returned. This function is threadsafe.
Types ¶
Click to show internal directories.
Click to hide internal directories.