Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

support for GOPACKAGESDRIVER env variable? #2755

Closed
jmhodges opened this issue Sep 17, 2019 · 5 comments
Closed

support for GOPACKAGESDRIVER env variable? #2755

jmhodges opened this issue Sep 17, 2019 · 5 comments

Comments

@jmhodges
Copy link

gopls, by way of golang.org/x/tools/go/packages, supports using the environment variable GOPACKAGESDRIVER to allow for build systems other than the go tooling (such as bazel) to provide the look ups for gopls.

However, there doesn't seem to be a way to set that env var as a workspace setting. I'm trying to help out with bazel's attempt at supporting gopls (documented at bazelbuild/rules_go#512 and https://github.com/bazelbuild/rules_go/wiki/Editor-and-tool-integration) which relies on this.

(While there's no godoc.org documentation of it, GOPACKAGESDRIVER is described in the go/packages code base in external.go)

Is there some way to set the GOPACKAGESDRIVER environment variable in my settings.json?

@jmhodges
Copy link
Author

(I also opened golang/go#34341 to get that env var documented in a more public way)

@jmhodges
Copy link
Author

Oh, I think I was reading outdated docs on the wiki? Is using go.toolsEnvVars the way to do this?

@jmhodges
Copy link
Author

Or maybe there's an undocumented gopls.env that I've seen mentioned in the vscode channel in the gophers slack?

@stamblerre
Copy link
Contributor

You can set the GOPACKAGESDRIVER used by gopls in 2 different ways, either:

"go.toolsEnvVars": {
    "GOPACKAGESDRIVER": "mygopackagesdriver"
} 

or

"gopls": {
    "env": {
        "GOPACKAGESDRIVER": "mygopackagesdriver"
    }
} 

The difference is that if you set "go.toolsEnvVars", the same driver will be used by any other tools that use go/packages that are used by VSCode. The configuration in the "gopls" settings just tells gopls to use that driver. It's also needed for editors that do not have a setting akin to "go.toolsEnvVars".

@ramya-rao-a
Copy link
Contributor

I agree with @stamblerre

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants