diff --git a/internal/lsp/cache/view.go b/internal/lsp/cache/view.go index f9a6ba7253..121f2fc3cd 100644 --- a/internal/lsp/cache/view.go +++ b/internal/lsp/cache/view.go @@ -126,10 +126,10 @@ type View struct { // Only possible with Go versions 1.14 and above. tmpMod bool - // noGopackagesDriver is true if the user has no value set for the - // GOPACKAGESDRIVER environment variable and no gopackagesdriver binary on + // hasGopackagesDriver is true if the user has a value set for the + // GOPACKAGESDRIVER environment variable or a gopackagesdriver binary on // their machine. - noGopackagesDriver bool + hasGopackagesDriver bool // `go env` variables that need to be tracked by gopls. gocache, gomodcache, gopath, goprivate string @@ -796,7 +796,7 @@ func (v *View) setBuildConfiguration() (isValid bool) { }() // Since we only really understand the `go` command, if the user has a // different GOPACKAGESDRIVER, assume that their configuration is valid. - if !v.noGopackagesDriver { + if v.hasGopackagesDriver { return true } // Check if the user is working within a module. @@ -871,7 +871,7 @@ func (v *View) setGoEnv(ctx context.Context, configEnv []string) (string, error) // A user may also have a gopackagesdriver binary on their machine, which // works the same way as setting GOPACKAGESDRIVER. tool, _ := exec.LookPath("gopackagesdriver") - v.noGopackagesDriver = gopackagesdriver == "off" || (gopackagesdriver == "" && tool == "") + v.hasGopackagesDriver = gopackagesdriver != "off" && (gopackagesdriver != "" || tool != "") return gomod, nil }