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>
This commit is contained in:
Rebecca Stambler 2020-08-06 11:01:14 -04:00
parent 6756e73834
commit f15f0bfc61
1 changed files with 5 additions and 1 deletions

View File

@ -12,6 +12,7 @@ import (
"io"
"io/ioutil"
"os"
"os/exec"
"path"
"path/filepath"
"reflect"
@ -862,8 +863,11 @@ func (v *View) setGoEnv(ctx context.Context, configEnv []string) (string, error)
}
// 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
}