annotation.go 414 B

1234567891011121314151617181920
  1. package util
  2. import (
  3. "strings"
  4. "github.com/tal-tech/go-zero/tools/goctl/api/spec"
  5. )
  6. func GetAnnotationValue(annos []spec.Annotation, key, field string) (string, bool) {
  7. for _, anno := range annos {
  8. if anno.Name == field && len(anno.Value) > 0 {
  9. return anno.Value, true
  10. }
  11. if anno.Name == key {
  12. value, ok := anno.Properties[field]
  13. return strings.TrimSpace(value), ok
  14. }
  15. }
  16. return "", false
  17. }