package annotation import ( "fmt" "reflect" "git.loafle.net/commons_go/logging" cur "git.loafle.net/commons_go/util/reflect" ) var annotationRegistry map[string]*AnnotationDefinition func init() { annotationRegistry = make(map[string]*AnnotationDefinition, 0) } 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) fRT, _, _ := cur.GetTypeInfo(t) def := &AnnotationDefinition{ t: t, rt: fRT, fields: meta, } annotationRegistry[name] = def } type AnnotationDefinition struct { t reflect.Type rt reflect.Type fields map[string]*AnnotationFieldMeta }