提交 a4a5d4b7 编写于 作者: Z zavla 提交者: Alessandro Arzilli

main_test: Fix "gopath mode" detection in projectRoot() (#1426)

* main_test: Fix "gopath mode" detection in projectRoot()

Fails detect that this is a "gopath mode" when GOPATH contains several paths ex. "d:\\dir\\gopath;f:\\dir\\gopath2"
上级 c7399ac2
......@@ -51,8 +51,13 @@ func projectRoot() string {
if err != nil {
panic(err)
}
if strings.Contains(wd, os.Getenv("GOPATH")) {
return filepath.Join(os.Getenv("GOPATH"), "src", "github.com", "derekparker", "delve")
gopaths := strings.FieldsFunc(os.Getenv("GOPATH"), func(r rune) bool { return r == os.PathListSeparator })
for _, curpath := range gopaths {
// Detects "gopath mode" when GOPATH contains several paths ex. "d:\\dir\\gopath;f:\\dir\\gopath2"
if strings.Contains(wd, curpath) {
return filepath.Join(curpath, "src", "github.com", "derekparker", "delve")
}
}
val, err := exec.Command("go", "list", "-m", "-f", "{{ .Dir }}").Output()
if err != nil {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册