mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-24 09:40:24 +08:00
24fb29a356
* change column to read from information_schema * reactor generate mode from datasource * reactor generate mode from datasource * add primary key check logic * resolve rebase conflicts * add naming style * add filename test case * resolve rebase conflicts * reactor test * add test case * change shell script to makefile * update rpc new * update gen_test.go * format code * format code * update test * generates alias
35 lines
740 B
Go
35 lines
740 B
Go
package generator
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"os"
|
|
"path/filepath"
|
|
|
|
"github.com/tal-tech/go-zero/tools/goctl/rpc/parser"
|
|
"github.com/tal-tech/go-zero/tools/goctl/util"
|
|
)
|
|
|
|
const configTemplate = `package config
|
|
|
|
import "github.com/tal-tech/go-zero/zrpc"
|
|
|
|
type Config struct {
|
|
zrpc.RpcServerConf
|
|
}
|
|
`
|
|
|
|
func (g *defaultGenerator) GenConfig(ctx DirContext, _ parser.Proto, namingStyle NamingStyle) error {
|
|
dir := ctx.GetConfig()
|
|
fileName := filepath.Join(dir.Filename, formatFilename("config", namingStyle)+".go")
|
|
if util.FileExists(fileName) {
|
|
return nil
|
|
}
|
|
|
|
text, err := util.LoadTemplate(category, configTemplateFileFile, configTemplate)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return ioutil.WriteFile(fileName, []byte(text), os.ModePerm)
|
|
}
|