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 }
| 19 | // return s.(configSelector), nil |
| 20 | // } |
| 21 | type Singleton interface { |
| 22 | // Return the encapsulated singleton |
| 23 | Get() (interface{}, error) |
| 24 | } |
| 25 | |
| 26 | // Call to create a new singleton that is instantiated with the given init function. |
| 27 | // init is not called until the first invocation of Get(). If init errors, it will be called again |
no outgoing calls
no test coverage detected