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().
(init SingletonInitFunc)
| 27 | // init is not called until the first invocation of Get(). If init errors, it will be called again |
| 28 | // on the next invocation of Get(). |
| 29 | func NewSingleton(init SingletonInitFunc) Singleton { |
| 30 | return &singletonImpl{init: init} |
| 31 | } |
| 32 | |
| 33 | type singletonImpl struct { |
| 34 | sync.Mutex |