go-zero/tools/goctl/api/util/annotation.go

21 lines
414 B
Go
Raw Normal View History

2020-07-29 17:11:41 +08:00
package util
import (
"strings"
"github.com/tal-tech/go-zero/tools/goctl/api/spec"
)
2020-07-29 17:11:41 +08:00
func GetAnnotationValue(annos []spec.Annotation, key, field string) (string, bool) {
for _, anno := range annos {
if anno.Name == field && len(anno.Value) > 0 {
return anno.Value, true
}
2020-07-29 17:11:41 +08:00
if anno.Name == key {
value, ok := anno.Properties[field]
return strings.TrimSpace(value), ok
2020-07-29 17:11:41 +08:00
}
}
return "", false
}