-
Notifications
You must be signed in to change notification settings - Fork 645
"Add Import" and "Go to definition" do not work with builtin packages #1636
Comments
only can not add import for me |
Both work fine for me. In the integrated terminal, run |
Setting GOROOT fixes the "Go to definition" issue, but not the "Add import" issue. Furthermore, IMO the plugin shouldn't require GOROOT to bet set, it seems better to obtain it with |
Where did you set the GOROOT? |
Before (both don't work):
After ("Go to definition" works; "Add import" does not work)
|
And where did you set the GOROOT? |
Outside; I opened VS Code with
|
@conradoplg I've pushed a fix to read GOROOT from
@uudashr The |
@ramya-rao-a @conradoplg
Now the question is "can vscode use non-standard go installation?" If it can, then probably that we should do. I think go compiler automatically use the |
@conradoplg @yuansushow |
I try to install golang on non-standard location
inside the docker container run
Output:
Make sure
|
My builtin packages have been behaving strangely as well, recently. It can see the builtin packages in the autocomplete list, like so: However, when I select one of the builtins to use, it says it can't find it: I have followed this wiki article and tried setting I don't want to have to hardcode the path to my Go install, because I'm using Homebrew on MacOS and that path will shift unpredictably with future versions. Versions:
|
|
Hi, @ramya-rao-a and thanks for investigating further! I removed all of my
This path lines up with Homebrew. 👌 |
Sorry for the delay. @ramya-rao-a yes, I confirm your change makes "Go to definition" work. Thanks! @uudashr Adding $GOROOT/bin to $PATH did not make "Add import" work. The output of
I think I found the issue. My "unusual" setup is the result of using the golang-backports Ubuntu ppa: https://launchpad.net/~longsleep/+archive/ubuntu/golang-backports
However, symlinks in GOROOT break some things like godoc. The Go team decided that "Symlinks in Go file trees should just be disallowed", and an issue was created in the golang-backports in order to change it to not use symlinks anymore.
So either:
While I personally think everything should work with symlinks, it seems that if the Go team gave up on that, so we can't do much about it. So I'll understand if you decide to close this issue, and I'll wait for the golang-backports people to "fix" it. |
I've just noticed that this is not limited to golang-backports. All Go packages in Ubuntu are like that, including default packages from LTS versions. So maybe that's an argument for changing gopkgs. |
@jlucktay Can you follow the steps in #1636 (comment) and see if that fixes the issue of the built in packages not appearing when running the command |
@ramya-rao-a on MacOS and Windows both, installing the |
@conradoplg try to re-install the Go tools
I've made some changes.. hopefully that fix the Ubuntu issues. |
@uudashr It works now! Thank you and @ramya-rao-a for the excellent work 👍 |
Cool |
"Go: Add Import" does not work with builtin Go packages, and "Go to definition" also doesn't work for builtin packages.
go version go1.10.1 linux/amd64
VS Code 1.22.2
Go plugin 0.6.78
The text was updated successfully, but these errors were encountered: