validate.go 408 B

123456789101112131415161718192021222324
  1. package validate
  2. import (
  3. "errors"
  4. "fmt"
  5. "github.com/logrusorgru/aurora"
  6. "github.com/tal-tech/go-zero/tools/goctl/api/parser"
  7. "github.com/urfave/cli"
  8. )
  9. func GoValidateApi(c *cli.Context) error {
  10. apiFile := c.String("api")
  11. if len(apiFile) == 0 {
  12. return errors.New("missing -api")
  13. }
  14. _, err := parser.Parse(apiFile)
  15. if err == nil {
  16. fmt.Println(aurora.Green("api format ok"))
  17. }
  18. return err
  19. }