-
Notifications
You must be signed in to change notification settings - Fork 645
go.inferGopath should not ignore global gopath #1525
Comments
Ran into this same exact issue. For now I'm ok with using a single go path instead of multiple, but it would be nice to reap the benefits of |
Yes, I also hope you can make the go.inferGopath better. For GOPATH, it is a global go path for all workspace; If we can use both of them in a workspace when set go.inferGopath to true, looks like use "$GOPATH:${workspaceRoot}" (but we cannot set this value to go.gopath, it is not absolute path), it will be more flexible. |
👍
|
The request for terminal to use the same GOPATH as rest of the features of the Go extension is being tracked in #1578. @merry-mongoose Can you explain a bit more on why having the setting |
@ramya-rao-a If I do this in system environment, it works well. But the project path should not be added into system environment. It will make the GOPATH variable too long if there are many projects. And also, it will make the trouble to team members. So, I need add it into project settings in vs code. There is a problem. the 'go.gopath' setting only allow the absolute path and '$workspaceRoot'. But I should not assign the absolute path which can work well on my machine to 'go.gopath' setting. it will make it cannot work on team members system after they pulled project from SCM. So, I hope I can do 1 of following 2 choices.
Thank you |
It seems that people are trying to solve some common issues by using the wrong tools without real understanding how their environment should be setup. Only thing, that is left to do: while in vscode terminal set $GPATH to point to both locations, something like: export GOPATH=$GOPATH:$(go_infer_path). I usually right click on the project folder and do open in terminal and execute: export GOPATH=$GOPATH:$(pwd). In short: there should be a setting in vscode that can enable something like this:
|
There are 2 separate problems here:
For the first one, I agree we should add the global gopath to the inferred gopath. The one thing I am not sold on is whether we should prepend the global gopath to the inferred gopath or append it. I lean on appending it, to keep the experience for folks who have been working with the inferred gopath consistent. Note: If Thoughts? |
Agreed, appending the global gopath would keep the experience consistent and would resolve the initial issue, without breaking any customized setups (or at least I can't think of a way that would). Even if it breaks something, one can always unset the global gopath as the default value for go tools is ~/go. |
This feature (including global gopath when |
I've read: https://github.com/Microsoft/vscode-go/wiki/GOPATH-in-the-VS-Code-Go-extension
Set path X in environment variable
$GOPATH
and setgo.inferGopath
totrue
which infers the path to be Y.Now If I go to the integrated terminal and
go get
any package, it will be installed in path X.But that's not where vscode is looking for it.
So, can we make it more useful by appending the inferred
$GOPATH
to the one from the environment variable or alternating the$GOPATH
so that the packages installed withgo get
from the integrated terminal are installed in the place where vscode will be looking for it?See this: https://stackoverflow.com/a/46047870
The text was updated successfully, but these errors were encountered: