This commit is contained in:
crusader 2018-03-15 23:38:47 +09:00
parent 219bb2f0c9
commit 64af0e5f73
2 changed files with 8 additions and 2 deletions

View File

@ -1,8 +1,11 @@
package annotation package annotation
import ( import (
"fmt"
"reflect" "reflect"
"git.loafle.net/commons_go/logging"
cdur "git.loafle.net/commons_go/di/util/reflect" cdur "git.loafle.net/commons_go/di/util/reflect"
) )
@ -13,6 +16,10 @@ func init() {
} }
func RegisterAnnotation(name string, t reflect.Type) { func RegisterAnnotation(name string, t reflect.Type) {
if _, ok := annotationRegistry[name]; ok {
logging.Logger().Panic(fmt.Sprintf("DI: name[%s] of annotation exist already.", name))
}
meta := getMetaFields(t) meta := getMetaFields(t)
fRT, _, _ := cdur.GetTypeInfo(t) fRT, _, _ := cdur.GetTypeInfo(t)

View File

@ -2,7 +2,6 @@ package registry
import ( import (
"fmt" "fmt"
"log"
"reflect" "reflect"
"runtime" "runtime"
"strings" "strings"
@ -50,7 +49,7 @@ func RegisterType(t reflect.Type) {
pc, _, _, ok := runtime.Caller(1) pc, _, _, ok := runtime.Caller(1)
details := runtime.FuncForPC(pc) details := runtime.FuncForPC(pc)
if ok && details != nil { if ok && details != nil {
log.Printf("called from %s\n", details.Name()) logging.Logger().Debug(fmt.Sprintf("called from %s", details.Name()))
} }
registry.RegisterType(t) registry.RegisterType(t)