diff --git a/annotation.go b/annotation.go index e01c75f..79bb52e 100644 --- a/annotation.go +++ b/annotation.go @@ -10,6 +10,8 @@ const ( NameTag = "@name" DefaultTag = "@default" RequiredTag = "@required" + + MethodAnnotationPrefix = "_" ) var ( diff --git a/registry.go b/registry.go index 39cfa9a..ca549c3 100644 --- a/registry.go +++ b/registry.go @@ -212,7 +212,11 @@ LOOP: if 0 == len(td.methodAnnotation) { td.methodAnnotation = make(map[string]map[reflect.Type]Annotation, 0) } - td.methodAnnotation[f.Name] = as + _name := strings.TrimLeft(f.Name, MethodAnnotationPrefix) + if "" == _name { + return nil, fmt.Errorf("name[%s] of method annotation is not valid", _name) + } + td.methodAnnotation[_name] = as continue LOOP } else { as, err := r.getAnnotation(&f)