From bcccfab82490ad70031621f4eddc184ccd5551a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=94=90=E5=B0=8F=E9=B8=AD?= Date: Sun, 25 Jun 2023 13:06:27 +0800 Subject: [PATCH] [fix] The directory is not recognized when it is in a soft link (#3337) --- tools/goctl/util/ctx/gomod.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/goctl/util/ctx/gomod.go b/tools/goctl/util/ctx/gomod.go index a5d67ba6..96e3c235 100644 --- a/tools/goctl/util/ctx/gomod.go +++ b/tools/goctl/util/ctx/gomod.go @@ -81,7 +81,12 @@ func getRealModule(workDir string, execRun execx.RunFunc) (*Module, error) { return nil, err } for _, m := range modules { - if strings.HasPrefix(workDir, m.Dir) { + mRealDir, err := pathx.ReadLink(m.Dir) + if err != nil { + return nil, fmt.Errorf("mod dir [%s] error: %w", m.Dir, err) + } + + if strings.HasPrefix(workDir, mRealDir) { return &m, nil } }