genconfig.go 495 B

123456789101112131415161718192021222324252627
  1. package gen
  2. import (
  3. "io/ioutil"
  4. "os"
  5. "path/filepath"
  6. "github.com/tal-tech/go-zero/tools/goctl/util"
  7. )
  8. const configTemplate = `package config
  9. import "github.com/tal-tech/go-zero/zrpc"
  10. type Config struct {
  11. zrpc.RpcServerConf
  12. }
  13. `
  14. func (g *defaultRpcGenerator) genConfig() error {
  15. configPath := g.dirM[dirConfig]
  16. fileName := filepath.Join(configPath, fileConfig)
  17. if util.FileExists(fileName) {
  18. return nil
  19. }
  20. return ioutil.WriteFile(fileName, []byte(configTemplate), os.ModePerm)
  21. }