From 430e8dc498567c71ed922e388245870fc6dc97e7 Mon Sep 17 00:00:00 2001 From: crusader Date: Tue, 4 Sep 2018 10:15:34 +0900 Subject: [PATCH] MethodAnnotationPrefix added --- annotation.go | 2 ++ registry.go | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) 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)