Singleton retrieves the singleton instance associated with the given name. Returns the instance and a boolean indicating its existence.
(name string)
| 225 | // Singleton retrieves the singleton instance associated with the given name. |
| 226 | // Returns the instance and a boolean indicating its existence. |
| 227 | func (d *DefaultContainer) Singleton(name string) (any, bool) { |
| 228 | d.muSingletons.Lock() |
| 229 | defer d.muSingletons.Unlock() |
| 230 | |
| 231 | if singleton, exists := d.singletons[name]; exists { |
| 232 | return singleton, true |
| 233 | } |
| 234 | |
| 235 | return nil, false |
| 236 | } |
| 237 | |
| 238 | // RemoveSingleton removes the singleton instance associated with the specified name. |
| 239 | func (d *DefaultContainer) RemoveSingleton(name string) error { |
no outgoing calls