Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Singleton ¶
type Singleton interface { // Return the encapsulated singleton Get() (interface{}, error) }
Interface for accessing singleton objects.
Example use: var configSelectorSingleton = NewSingleton(init)
func configSelector() (configSelector, error) { s, err := configSelectorSingleton.Get() if err != nil { return nil, err } return s.(configSelector), nil }
func NewSingleton ¶
func NewSingleton(init SingletonInitFunc) Singleton
Call to create a new singleton that is instantiated with the given init function. init is not called until the first invocation of Get(). If init errors, it will be called again on the next invocation of Get().
type SingletonInitFunc ¶
type SingletonInitFunc func() (interface{}, error)
Click to show internal directories.
Click to hide internal directories.