refactor file|path (#1409)
Co-authored-by: anqiansong <anqiansong@bytedance.com>
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
"github.com/logrusorgru/aurora"
|
||||
"github.com/tal-tech/go-zero/tools/goctl/util"
|
||||
"github.com/tal-tech/go-zero/tools/goctl/util/pathx"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
@@ -46,7 +47,7 @@ func ApiCommand(c *cli.Context) error {
|
||||
return errors.New("missing -o")
|
||||
}
|
||||
|
||||
fp, err := util.CreateIfNotExist(apiFile)
|
||||
fp, err := pathx.CreateIfNotExist(apiFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -62,15 +63,15 @@ func ApiCommand(c *cli.Context) error {
|
||||
}
|
||||
|
||||
if len(home) > 0 {
|
||||
util.RegisterGoctlHome(home)
|
||||
pathx.RegisterGoctlHome(home)
|
||||
}
|
||||
|
||||
text, err := util.LoadTemplate(category, apiTemplateFile, apiTemplate)
|
||||
text, err := pathx.LoadTemplate(category, apiTemplateFile, apiTemplate)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
baseName := util.FileNameWithoutExt(filepath.Base(apiFile))
|
||||
baseName := pathx.FileNameWithoutExt(filepath.Base(apiFile))
|
||||
if strings.HasSuffix(strings.ToLower(baseName), "-api") {
|
||||
baseName = baseName[:len(baseName)-4]
|
||||
} else if strings.HasSuffix(strings.ToLower(baseName), "api") {
|
||||
|
||||
Reference in New Issue
Block a user