fix go module related issues

This commit is contained in:
therecipe 2019-10-20 00:43:06 +02:00
parent 0491386233
commit 1097424d65
3 changed files with 11 additions and 7 deletions

View file

@ -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" importAs := "custom_" + ipkg + "_" + cls[0].Hash() + "m"
if strings.Contains(spath, "/vendor/") { if strings.Contains(spath, "/vendor/") && !utils.UseGOMOD(path) {
importAs = ipkg 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 } else if _, ok := parser.State.GoClassMap[class.Name]; !ok { //TODO: support proper namespaces instead
ipkg := file.Name.String() ipkg := file.Name.String()
importAs := "custom_" + ipkg + "_" + class.Hash() + "m" importAs := "custom_" + ipkg + "_" + class.Hash() + "m"
if strings.Contains(path, "/vendor/") { if strings.Contains(path, "/vendor/") && !utils.UseGOMOD(path) {
importAs = ipkg importAs = ipkg
} }
class.Module = importAs class.Module = importAs

View file

@ -27,10 +27,14 @@ func Check(target string, docker, vagrant bool) {
} }
hash := "please install git" hash := "please install git"
if _, err := exec.LookPath("git"); err == nil { if utils.UseGOMOD("") {
cmd := exec.Command("git", "rev-parse", "--verify", "HEAD") hash = utils.GoListOptional("{{.Version}}", "github.com/therecipe/qt", "-m", "get qt hash")
cmd.Dir = utils.GoQtPkgPath() } else {
hash = strings.TrimSpace(utils.RunCmdOptional(cmd, "get git hash")) 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{ vars := [][]string{

View file

@ -23,7 +23,7 @@ func GOPATH() string { return envOr("GOPATH", build.Default.GOPATH) }
func MustGoPath() string { func MustGoPath() string {
mustGoPathMutex.Lock() mustGoPathMutex.Lock()
if mustGoPath == "" { 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")) mustGoPath = strings.TrimSpace(RunCmd(GoList("{{.Root}}", PackageName, "-find"), "get list gopath"))
} }
if mustGoPath == "" { if mustGoPath == "" {