Files
go-zero/tools/goctl/rpc/gen/genconfig.go
Keson 41964f9d52 gozero template (#147)
* model/rpc generate code from template cache

* delete unused(deprecated) code

* support template init|update|clean|revert

* model: return the execute result for insert and update operation

* // deprecated: containsAny

* add template test

* add default buildVersion

* update build version
2020-10-21 14:59:35 +08:00

34 lines
602 B
Go

package gen
import (
"io/ioutil"
"os"
"path/filepath"
"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 *defaultRpcGenerator) genConfig() error {
configPath := g.dirM[dirConfig]
fileName := filepath.Join(configPath, fileConfig)
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)
}