From 857a19d0bffef27ef42ed8c5c93c793d998f7591 Mon Sep 17 00:00:00 2001 From: gedi Date: Thu, 27 Sep 2018 16:04:42 +0300 Subject: [PATCH] should close #136 --- builder_go110.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/builder_go110.go b/builder_go110.go index 9536dda..c4ae376 100644 --- a/builder_go110.go +++ b/builder_go110.go @@ -326,11 +326,16 @@ func buildTestMain(pkg *build.Package) ([]byte, bool, error) { return nil, false, err } contexts = ctxs - // @TODO: is it a good indicator for packages outside GOPATH - if strings.Index(pkg.ImportPath, "_/") == 0 { - importPath = pkg.Name - } else { + + // for module support, query the module import path + // @TODO: maybe there is a better way to read it + out, err := exec.Command("go", "list", "-m").CombinedOutput() + if err != nil { + // is not using modules or older go version importPath = pkg.ImportPath + } else { + // otherwise read the module name from command output + importPath = strings.TrimSpace(string(out)) } name = pkg.Name }