Skip to content

🎧 Your Personal Streaming Service

Fixed a problem with the injection code

Deluanf3ba23ef4191
diff --git a/utils/graph.go b/utils/graph.go
index f37d6ee36..9aacb449a 100644
--- a/utils/graph.go
+++ b/utils/graph.go
@@ -13,12 +13,14 @@ var (
func DefineSingleton(ptr interface{}, constructor interface{}, args ...interface{}) {
typ := reflect.TypeOf(ptr)
- if definitions[typ] == nil {
- Graph.Define(ptr, inject.NewProvider(constructor, args...))
+ provider := inject.NewProvider(constructor, args...)
+
+ if _, found := definitions[typ]; found {
+ ptr = definitions[typ]
} else {
- Graph.Define(definitions[typ], inject.NewProvider(constructor, args...))
+ definitions[typ] = ptr
}
- definitions[typ] = ptr
+ Graph.Define(ptr, provider)
}
func init() {