MethodAnnotationPrefix added

This commit is contained in:
crusader 2018-09-04 10:15:34 +09:00
parent ef45ff4ad6
commit 430e8dc498
2 changed files with 7 additions and 1 deletions

View File

@ -10,6 +10,8 @@ const (
NameTag = "@name" NameTag = "@name"
DefaultTag = "@default" DefaultTag = "@default"
RequiredTag = "@required" RequiredTag = "@required"
MethodAnnotationPrefix = "_"
) )
var ( var (

View File

@ -212,7 +212,11 @@ LOOP:
if 0 == len(td.methodAnnotation) { if 0 == len(td.methodAnnotation) {
td.methodAnnotation = make(map[string]map[reflect.Type]Annotation, 0) 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 continue LOOP
} else { } else {
as, err := r.getAnnotation(&f) as, err := r.getAnnotation(&f)