diff --git a/registry.go b/registry.go index 927240e..22ee4c3 100644 --- a/registry.go +++ b/registry.go @@ -6,7 +6,6 @@ import ( "reflect" "strings" - "git.loafle.net/loafer/annotation-go/annotations" luReflect "git.loafle.net/loafer/util-go/reflect" ) @@ -25,7 +24,7 @@ type Regist interface { // Register is method Register(t reflect.Type) error // Parse is method - Parse(tag reflect.StructTag) (map[reflect.Type]annotations.Annotation, error) + Parse(tag reflect.StructTag) (map[reflect.Type]Annotation, error) } // Registry is struct @@ -71,12 +70,12 @@ func (r *Registry) Register(t reflect.Type) error { } // Parse is method -func Parse(tag reflect.StructTag) (map[reflect.Type]annotations.Annotation, error) { +func Parse(tag reflect.StructTag) (map[reflect.Type]Annotation, error) { return registry.Parse(tag) } // Parse is method -func (r *Registry) Parse(tag reflect.StructTag) (map[reflect.Type]annotations.Annotation, error) { +func (r *Registry) Parse(tag reflect.StructTag) (map[reflect.Type]Annotation, error) { s := strings.Trim(tag.Get(AnnotationTag), " ") if "" == s { return nil, nil @@ -91,7 +90,7 @@ func (r *Registry) Parse(tag reflect.StructTag) (map[reflect.Type]annotations.An return nil, nil } - rKVs := make(map[reflect.Type]annotations.Annotation, 0) + rKVs := make(map[reflect.Type]Annotation, 0) for name, attributes := range am { t, annotation, err := r.buildAnnotation(name, attributes) if nil != err { @@ -113,7 +112,7 @@ func (r *Registry) getTypeAnnotationField(t reflect.Type) *reflect.StructField { f := rt.Field(i) if f.Anonymous { - if f.Type == annotations.TypeAnnotationType { + if f.Type == TypeAnnotationType { return &f } } @@ -154,14 +153,14 @@ func (r *Registry) splitAnnotation(s string) (map[string]string, error) { return ss, nil } -func (r *Registry) buildAnnotation(name string, attributes string) (reflect.Type, annotations.Annotation, error) { +func (r *Registry) buildAnnotation(name string, attributes string) (reflect.Type, Annotation, error) { def, ok := r.definitions[name] if !ok { return nil, nil, fmt.Errorf("There is no annotation[%s]", name) } v := reflect.New(def.rt) - i := v.Interface().(annotations.Annotation) + i := v.Interface().(Annotation) if "" != attributes { _json := fmt.Sprintf("{%s}", attributes) diff --git a/registry_test.go b/registry_test.go index cf66669..26824c8 100644 --- a/registry_test.go +++ b/registry_test.go @@ -1,7 +1,6 @@ package annotation import ( - "git.loafle.net/loafer/annotation-go/annotations" "reflect" "testing" ) @@ -70,7 +69,7 @@ func TestParse(t *testing.T) { tests := []struct { name string args args - want map[reflect.Type]annotations.Annotation + want map[reflect.Type]Annotation wantErr bool }{ // TODO: Add test cases. @@ -100,7 +99,7 @@ func TestRegistry_Parse(t *testing.T) { name string fields fields args args - want map[reflect.Type]annotations.Annotation + want map[reflect.Type]Annotation wantErr bool }{ // TODO: Add test cases. @@ -222,7 +221,7 @@ func TestRegistry_buildAnnotation(t *testing.T) { fields fields args args want reflect.Type - want1 annotations.Annotation + want1 Annotation wantErr bool }{ // TODO: Add test cases. diff --git a/annotations/annotations.go b/types.go similarity index 96% rename from annotations/annotations.go rename to types.go index c0e3611..c2dad7d 100644 --- a/annotations/annotations.go +++ b/types.go @@ -1,4 +1,4 @@ -package annotations +package annotation import "reflect"