From f3ba23ef419134e330cbbd4f2fd6d860e4d630f6 Mon Sep 17 00:00:00 2001 From: Deluan Date: Thu, 3 Mar 2016 13:14:05 -0500 Subject: [PATCH] Fixed a problem with the injection code --- utils/graph.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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() {