You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
go-zero/tools/goctl/api/validate/validate.go

26 lines
469 B
Go

4 years ago
package validate
import (
"errors"
"fmt"
"github.com/logrusorgru/aurora"
"github.com/tal-tech/go-zero/tools/goctl/api/parser"
4 years ago
"github.com/urfave/cli"
)
// GoValidateApi verifies whether the api has a syntax error
4 years ago
func GoValidateApi(c *cli.Context) error {
apiFile := c.String("api")
if len(apiFile) == 0 {
return errors.New("missing -api")
}
_, err := parser.Parse(apiFile)
4 years ago
if err == nil {
fmt.Println(aurora.Green("api format ok"))
}
return err
}