2 Star 0 Fork 338

hxchjm / go-zero

forked from kevwan / go-zero 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
gen.go 842 Bytes
一键复制 编辑 原始数据 按行查看 历史
kingxt 提交于 2021-01-11 15:10 . feature: refactor api parse to g4 (#365)
package tsgen
import (
"errors"
"fmt"
"github.com/logrusorgru/aurora"
"github.com/tal-tech/go-zero/core/logx"
"github.com/tal-tech/go-zero/tools/goctl/api/parser"
"github.com/tal-tech/go-zero/tools/goctl/util"
"github.com/urfave/cli"
)
func TsCommand(c *cli.Context) error {
apiFile := c.String("api")
dir := c.String("dir")
webApi := c.String("webapi")
caller := c.String("caller")
unwrapApi := c.Bool("unwrap")
if len(apiFile) == 0 {
return errors.New("missing -api")
}
if len(dir) == 0 {
return errors.New("missing -dir")
}
api, err := parser.Parse(apiFile)
if err != nil {
fmt.Println(aurora.Red("Failed"))
return err
}
logx.Must(util.MkdirIfNotExist(dir))
logx.Must(genHandler(dir, webApi, caller, api, unwrapApi))
logx.Must(genComponents(dir, api))
fmt.Println(aurora.Green("Done."))
return nil
}
Go
1
https://gitee.com/hxchjm/go-zero.git
git@gitee.com:hxchjm/go-zero.git
hxchjm
go-zero
go-zero
3eb88c4e4bf1

搜索帮助