-
Notifications
You must be signed in to change notification settings - Fork 819
Change GOMODCACHE #1504
-
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
Beta Was this translation helpful? Give feedback.
All reactions
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
-
Your problem is not vscode-go related, run go help env
Beta Was this translation helpful? Give feedback.
All reactions
-
Try to set GOMODCACHE
using "go.toolsEnvVars"
instead of gopls
setting. https://github.com/golang/vscode-go/blob/master/docs/settings.md#gotoolsenvvars
Beta Was this translation helpful? Give feedback.
All reactions
-
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"
.
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1
-
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.
Beta Was this translation helpful? Give feedback.