Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Change GOMODCACHE #1504

Answered by stamblerre
UncleVic asked this question in Help
Discussion options

Hi there,

How can I change GOMODCACHE?
I don't want installing modules to $HOME/go

I tried to set

 "gopls": {
 "build.env": {
 "GOPATH": "path/go",
 "GOMODCACHE": "path/go/pkg/mod"
 }
 },

But it doesn't work :(

Thx

You must be logged in to vote

Setting GOMODCACHE through the VS Code or gopls settings will only affect the value of that environment variable when you are in the editor or the integrated terminal. To set it globally, you will want to run go env -w GOMODCACHE="path/go/pkg/mod".

Replies: 3 comments 1 reply

Comment options

Your problem is not vscode-go related, run go help env

You must be logged in to vote
0 replies
Comment options

Try to set GOMODCACHE using "go.toolsEnvVars" instead of gopls setting. https://github.com/golang/vscode-go/blob/master/docs/settings.md#gotoolsenvvars

You must be logged in to vote
0 replies
Comment options

Setting GOMODCACHE through the VS Code or gopls settings will only affect the value of that environment variable when you are in the editor or the integrated terminal. To set it globally, you will want to run go env -w GOMODCACHE="path/go/pkg/mod".

You must be logged in to vote
1 reply
Comment options

Right. If you want the change applied globally in the machine, go env -w is the way to do so. Also, the "go.toolsEnvVars" setting applies only to tools run by the extension, and doesn't apply to the integrated terminal.

Answer selected by hyangah
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /