2020-08-29 00:15:15 +08:00
|
|
|
package gen
|
2020-08-28 19:24:58 +08:00
|
|
|
|
|
|
|
import (
|
|
|
|
"io/ioutil"
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
|
|
|
|
"github.com/tal-tech/go-zero/tools/goctl/util"
|
|
|
|
)
|
|
|
|
|
2020-08-28 21:22:35 +08:00
|
|
|
const configTemplate = `package config
|
2020-08-28 19:24:58 +08:00
|
|
|
|
2020-09-18 11:41:52 +08:00
|
|
|
import "github.com/tal-tech/go-zero/zrpc"
|
2020-08-28 19:24:58 +08:00
|
|
|
|
2020-08-28 21:22:35 +08:00
|
|
|
type Config struct {
|
2020-09-18 11:41:52 +08:00
|
|
|
zrpc.RpcServerConf
|
2020-08-28 21:22:35 +08:00
|
|
|
}
|
2020-08-28 19:24:58 +08:00
|
|
|
`
|
|
|
|
|
|
|
|
func (g *defaultRpcGenerator) genConfig() error {
|
|
|
|
configPath := g.dirM[dirConfig]
|
|
|
|
fileName := filepath.Join(configPath, fileConfig)
|
|
|
|
if util.FileExists(fileName) {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return ioutil.WriteFile(fileName, []byte(configTemplate), os.ModePerm)
|
|
|
|
}
|