package registry import ( "reflect" "testing" cda "git.loafle.net/commons_go/di/annotation" ) func TestRegisterType(t *testing.T) { RegisterType(reflect.TypeOf((*TestStruct1)(nil)), &cda.ComponentAnnotation{}) RegisterType(reflect.TypeOf((*TestStruct2)(nil)), &cda.ComponentAnnotation{ Name: "test1", }) RegisterType(reflect.TypeOf((*TestStruct3)(nil)), &cda.ComponentAnnotation{ Name: "test2", }) } type TestStruct1 struct { Name1 string `annotation:"@Inject"` Name2 string `annotation:"@Inject()"` Name3 string `annotation:"@Inject(name=test1)"` } type TestStruct2 struct { Name1 string `annotation:"@Inject"` Name2 string `annotation:"@Inject()"` Name3 string `annotation:"@Inject(name=test2)"` } type TestStruct3 struct { Name1 string `annotation:"@Inject"` Name2 string `annotation:"@Inject()"` Name3 string `annotation:"@Inject(name=test3)"` }