deal with modules inside the gopath
Этот коммит содержится в:
родитель
479842c91e
коммит
f92dc4c9b7
1 изменённых файлов: 8 добавлений и 2 удалений
|
@ -317,7 +317,7 @@ func buildTestMain(pkg *build.Package) ([]byte, bool, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, false, err
|
return nil, false, err
|
||||||
}
|
}
|
||||||
importPath = parseImport(pkg.ImportPath)
|
importPath = parseImport(pkg.ImportPath, pkg.Root)
|
||||||
name = pkg.Name
|
name = pkg.Name
|
||||||
} else {
|
} else {
|
||||||
name = "main"
|
name = "main"
|
||||||
|
@ -339,7 +339,13 @@ func buildTestMain(pkg *build.Package) ([]byte, bool, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// parseImport parses the import path to deal with go module.
|
// parseImport parses the import path to deal with go module.
|
||||||
func parseImport(rawPath string) string {
|
func parseImport(rawPath, rootPath string) string {
|
||||||
|
// with go > 1.11 and go module enabled out of the GOPATH,
|
||||||
|
// the import path begins with an underscore and the GOPATH is unknown on build.
|
||||||
|
if rootPath != "" {
|
||||||
|
// go < 1.11 or it's a module inside the GOPATH
|
||||||
|
return rawPath
|
||||||
|
}
|
||||||
// for module support, query the module import path
|
// for module support, query the module import path
|
||||||
cmd := exec.Command("go", "list", "-m", "-json")
|
cmd := exec.Command("go", "list", "-m", "-json")
|
||||||
out, err := cmd.StdoutPipe()
|
out, err := cmd.StdoutPipe()
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче