refactor file|path (#1409)

Co-authored-by: anqiansong <anqiansong@bytedance.com>
This commit is contained in:
anqiansong
2022-01-03 21:32:40 +08:00
committed by GitHub
parent 290de6aa96
commit 89ce5e492b
81 changed files with 279 additions and 245 deletions

View File

@@ -5,6 +5,7 @@ import (
"strings"
"github.com/tal-tech/go-zero/tools/goctl/util"
"github.com/tal-tech/go-zero/tools/goctl/util/pathx"
"github.com/tal-tech/go-zero/tools/goctl/util/stringx"
)
@@ -29,13 +30,13 @@ service {{.serviceName}} {
func ProtoTmpl(out string) error {
protoFilename := filepath.Base(out)
serviceName := stringx.From(strings.TrimSuffix(protoFilename, filepath.Ext(protoFilename)))
text, err := util.LoadTemplate(category, rpcTemplateFile, rpcTemplateText)
text, err := pathx.LoadTemplate(category, rpcTemplateFile, rpcTemplateText)
if err != nil {
return err
}
dir := filepath.Dir(out)
err = util.MkdirIfNotExist(dir)
err = pathx.MkdirIfNotExist(dir)
if err != nil {
return err
}