feat(goctl): support go work (#4332) (#4344)

This commit is contained in:
ningzi
2025-02-05 22:22:40 +08:00
committed by GitHub
parent af7cf79963
commit 77fb271a06
4 changed files with 80 additions and 3 deletions

View File

@@ -7,7 +7,7 @@ import (
"github.com/zeromicro/go-zero/tools/goctl/rpc/execx"
)
// IsGoMod is used to determine whether workDir is a go module project through command `go list -json -m`
// IsGoMod is used to determine whether workDir is a go module project through command `go env GOMOD`
func IsGoMod(workDir string) (bool, error) {
if len(workDir) == 0 {
return false, errors.New("the work directory is not found")
@@ -16,8 +16,8 @@ func IsGoMod(workDir string) (bool, error) {
return false, err
}
data, err := execx.Run("go list -m -f '{{.GoMod}}'", workDir)
if err != nil || len(data) == 0 {
data, err := execx.Run("go env GOMOD", workDir)
if err != nil || data == "/dev/null" {
return false, nil
}