internal/lsp/cache: check for a gopackagesdriver binary
We missed a possible case in checking for gopackagesdriver - a binary
named gopackagesdriver works the same way as setting GOPACKAGESDRIVER.
Change-Id: I676800d253950cb35d74211558bafab340310653
Reviewed-on: https://go-review.googlesource.com/c/tools/+/247179
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
diff --git a/internal/lsp/cache/view.go b/internal/lsp/cache/view.go
index 3fbaa68..372a16f 100644
--- a/internal/lsp/cache/view.go
+++ b/internal/lsp/cache/view.go
@@ -12,6 +12,7 @@
"io"
"io/ioutil"
"os"
+ "os/exec"
"path"
"path/filepath"
"reflect"
@@ -862,8 +863,11 @@
}
// The value of GOPACKAGESDRIVER is not returned through the go command.
+ // A user may also have a gopackagesdriver binary on their machine, which
+ // works the same way as setting GOPACKAGESDRIVER.
gopackagesdriver := os.Getenv("GOPACKAGESDRIVER")
- v.goCommand = gopackagesdriver == "" || gopackagesdriver == "off"
+ tool, _ := exec.LookPath("gopackagesdriver")
+ v.goCommand = tool == "" && (gopackagesdriver == "" || gopackagesdriver == "off")
return gomod, nil
}