package di // @Inject(name? string) import ( "reflect" "git.loafle.net/loafer/annotation-go" ) func init() { if err := annotation.Register(ComponentAnnotationType); nil != err { panic(err) } if err := annotation.Register(InjectAnnotationType); nil != err { panic(err) } if err := annotation.Register(ResourceAnnotationType); nil != err { panic(err) } } var ComponentAnnotationType = reflect.TypeOf((*ComponentAnnotation)(nil)) type ComponentAnnotation struct { annotation.TypeAnnotation `@annotation:"@Component"` Name string `json:"name"` InitMethod string `json:"initMethod"` // func (receiver interface{}, cr ComponentRegistry) error DestroyMethod string `json:"destroyMethod"` // func (receiver interface{}, cr ComponentRegistry) error } var InjectAnnotationType = reflect.TypeOf((*InjectAnnotation)(nil)) type InjectAnnotation struct { annotation.TypeAnnotation `@annotation:"@Inject"` Name string `json:"name"` } var ResourceAnnotationType = reflect.TypeOf((*ResourceAnnotation)(nil)) type ResourceAnnotation struct { annotation.TypeAnnotation `@annotation:"@Resource"` Name string `json:"name"` }