mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-24 18:00:24 +08:00
26 lines
470 B
Go
26 lines
470 B
Go
package validate
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
|
|
"github.com/logrusorgru/aurora"
|
|
"github.com/zeromicro/go-zero/tools/goctl/api/parser"
|
|
"github.com/urfave/cli"
|
|
)
|
|
|
|
// GoValidateApi verifies whether the api has a syntax error
|
|
func GoValidateApi(c *cli.Context) error {
|
|
apiFile := c.String("api")
|
|
|
|
if len(apiFile) == 0 {
|
|
return errors.New("missing -api")
|
|
}
|
|
|
|
_, err := parser.Parse(apiFile)
|
|
if err == nil {
|
|
fmt.Println(aurora.Green("api format ok"))
|
|
}
|
|
return err
|
|
}
|