feat(goctl): go work multi-module support (#1800)

* feat(goctl): go work multi-module support

Resolve: #1793

* chore: print log when getting project ctx fails
This commit is contained in:
Fyn
2022-04-18 20:36:41 +08:00
committed by GitHub
parent 92b450eb11
commit e62870e268
5 changed files with 118 additions and 17 deletions

View File

@@ -4,7 +4,6 @@ import (
"errors"
"os"
"github.com/zeromicro/go-zero/core/jsonx"
"github.com/zeromicro/go-zero/tools/goctl/rpc/execx"
)
@@ -17,16 +16,10 @@ func IsGoMod(workDir string) (bool, error) {
return false, err
}
data, err := execx.Run("go list -json -m", workDir)
if err != nil {
data, err := execx.Run("go list -m -f '{{.GoMod}}'", workDir)
if err != nil || len(data) == 0 {
return false, nil
}
var m Module
err = jsonx.Unmarshal([]byte(data), &m)
if err != nil {
return false, err
}
return len(m.GoMod) > 0, nil
return true, nil
}