From 2b815162f6a344ef3633ddec131aa6e89a5a7583 Mon Sep 17 00:00:00 2001 From: kingxt Date: Mon, 7 Sep 2020 18:12:03 +0800 Subject: [PATCH] refactor (#48) * rebase upstream * rebase * trim no need line * trim no need line * trim no need line * refactor gomod module logic Co-authored-by: kingxt --- tools/goctl/util/project/project.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/goctl/util/project/project.go b/tools/goctl/util/project/project.go index ff5b4117..954753a4 100644 --- a/tools/goctl/util/project/project.go +++ b/tools/goctl/util/project/project.go @@ -87,7 +87,12 @@ func Prepare(projectDir string, checkGrpcEnv bool) (*Project, error) { } if !strings.HasPrefix(pwd, src) { - name = filepath.Clean(filepath.Base(projectDir)) + absPath, err := filepath.Abs(projectDir) + if err != nil { + return nil, err + } + + name = filepath.Clean(filepath.Base(absPath)) path = projectDir } else { r := strings.TrimPrefix(pwd, src+string(filepath.Separator))