From fa0c3649824013b3d8393e9399d4b952132828e4 Mon Sep 17 00:00:00 2001 From: Kevin Wan Date: Fri, 12 Nov 2021 14:05:28 +0800 Subject: [PATCH] fixes #1169 (#1229) --- tools/goctl/docker/docker.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tools/goctl/docker/docker.go b/tools/goctl/docker/docker.go index fc7d2b3d..da40b955 100644 --- a/tools/goctl/docker/docker.go +++ b/tools/goctl/docker/docker.go @@ -120,11 +120,6 @@ func generateDockerfile(goFile string, port int, version string, args ...string) if len(projPath) == 0 { projPath = "." - } else { - pos := strings.IndexByte(projPath, os.PathSeparator) - if pos >= 0 { - projPath = projPath[pos+1:] - } } out, err := util.CreateIfNotExist(dockerfileName) @@ -169,6 +164,12 @@ func getFilePath(file string) (string, error) { if err != nil { return "", errors.New("no go.mod found, or not in GOPATH") } + + // ignore project root directory for GOPATH mode + pos := strings.IndexByte(projPath, os.PathSeparator) + if pos >= 0 { + projPath = projPath[pos+1:] + } } return projPath, nil