diff --git a/internal/cmd/moc/moc.go b/internal/cmd/moc/moc.go index b5b40a39..f7eba344 100644 --- a/internal/cmd/moc/moc.go +++ b/internal/cmd/moc/moc.go @@ -201,7 +201,7 @@ func moc(path, target, tags string, fast, slow, root bool, l int, dirty bool) { } importAs := "custom_" + ipkg + "_" + cls[0].Hash() + "m" - if strings.Contains(spath, "/vendor/") { + if strings.Contains(spath, "/vendor/") && !utils.UseGOMOD(path) { importAs = ipkg } @@ -727,7 +727,7 @@ func parse(path string) ([]*parser.Class, string, error) { } else if _, ok := parser.State.GoClassMap[class.Name]; !ok { //TODO: support proper namespaces instead ipkg := file.Name.String() importAs := "custom_" + ipkg + "_" + class.Hash() + "m" - if strings.Contains(path, "/vendor/") { + if strings.Contains(path, "/vendor/") && !utils.UseGOMOD(path) { importAs = ipkg } class.Module = importAs diff --git a/internal/cmd/setup/check.go b/internal/cmd/setup/check.go index df86cafb..5f6a7092 100644 --- a/internal/cmd/setup/check.go +++ b/internal/cmd/setup/check.go @@ -27,10 +27,14 @@ func Check(target string, docker, vagrant bool) { } hash := "please install git" - if _, err := exec.LookPath("git"); err == nil { - cmd := exec.Command("git", "rev-parse", "--verify", "HEAD") - cmd.Dir = utils.GoQtPkgPath() - hash = strings.TrimSpace(utils.RunCmdOptional(cmd, "get git hash")) + if utils.UseGOMOD("") { + hash = utils.GoListOptional("{{.Version}}", "github.com/therecipe/qt", "-m", "get qt hash") + } else { + if _, err := exec.LookPath("git"); err == nil { + cmd := exec.Command("git", "rev-parse", "--verify", "HEAD") + cmd.Dir = utils.GoQtPkgPath() + hash = strings.TrimSpace(utils.RunCmdOptional(cmd, "get git hash")) + } } vars := [][]string{ diff --git a/internal/utils/gopath.go b/internal/utils/gopath.go index d119358f..c3174303 100644 --- a/internal/utils/gopath.go +++ b/internal/utils/gopath.go @@ -23,7 +23,7 @@ func GOPATH() string { return envOr("GOPATH", build.Default.GOPATH) } func MustGoPath() string { mustGoPathMutex.Lock() if mustGoPath == "" { - if _, err := exec.LookPath("go"); err == nil { + if _, err := exec.LookPath("go"); err == nil && !UseGOMOD("") { mustGoPath = strings.TrimSpace(RunCmd(GoList("{{.Root}}", PackageName, "-find"), "get list gopath")) } if mustGoPath == "" {