diff --git a/tools/goctl/api/gogen/util.go b/tools/goctl/api/gogen/util.go index 55b65ff3..b89b787b 100644 --- a/tools/goctl/api/gogen/util.go +++ b/tools/goctl/api/gogen/util.go @@ -22,8 +22,8 @@ func getParentPackage(dir string) (string, error) { if err != nil { return "", err } - absDir = strings.ReplaceAll(absDir, `\`, `/`) + absDir = strings.ReplaceAll(absDir, `\`, `/`) var rootPath string var tempPath = absDir var hasGoMod = false diff --git a/tools/goctl/util/path.go b/tools/goctl/util/path.go index 8446b4bb..9c092688 100644 --- a/tools/goctl/util/path.go +++ b/tools/goctl/util/path.go @@ -4,7 +4,6 @@ import ( "fmt" "os" "path" - "path/filepath" "strings" "github.com/tal-tech/go-zero/tools/goctl/vars" @@ -44,16 +43,3 @@ func PathFromGoSrc() (string, error) { // skip slash return dir[len(parent)+1:], nil } - -func GetParentPackage(dir string) (string, error) { - absDir, err := filepath.Abs(dir) - if err != nil { - return "", err - } - pos := strings.Index(absDir, vars.ProjectName) - if pos < 0 { - return "", fmt.Errorf("error dir:[%s],please make sure that your project is in the %s directory", vars.ProjectName, dir) - } - - return absDir[pos:], nil -}