-
Notifications
You must be signed in to change notification settings - Fork 645
Incorrect import by auto-complete when pkgname != last part of pkg path #647
Comments
@AlekSi There are 2 separate things at play here.
For the first issue, I have a PR out: #659 For the second, I am curious. Is it very common to have the vendor folder right under #GOPATH/src ? |
It has nothing to do with As mentioned several times before, package name is defined by |
@AlekSi First off, thanks for your patience. I now understand that the last element in the import path need not always be the package name. It is just convention for predictability's sake that most of the time the package name is the same as the last element in the import path. The list of packages that appear in the auto-complete comes from the output of the
We could try out a few options and compare performance
Until then, I would keep the fix in cb0d2bc because it atleast takes us one step closer to the ideal solution where versioned packages from gopkg.in will get the package name without the version number. Thoughts? |
* 'master' of github.com:mattetti/vscode-go: (128 commits) Add telemetry support for the Go extension Add dlv path to error msg when dlv not found Fixes microsoft#465 outline offset problem in No-English language (microsoft#699) fix coverage display when editor changes to undefined (microsoft#693) Add support for reading http.proxy setting (microsoft#639) Fixing flaky unit tests Refactor for corner cases Reduce noise in console log due to errors from hover Changelog for next update 0.6.51 Remove space after brackets in snippet as per microsoft#628 Fixes microsoft#647 Strip version from autocompleted pkgs from gopkg.in (microsoft#659) Fixes microsoft#647 Support vendor pkgs from root of GOPATH/src (microsoft#660) Fixes microsoft#640 Use spawn to handle big data from gocode (microsoft#661) Fixed wrong workspace when one gopath is the substring of another. (microsoft#658) Fix "gotests" when generates test for current function for type methods (microsoft#657) Add benchmark function snippet (microsoft#648) Fix "Go to Definition" when running Go HEAD (microsoft#655) Fixes microsoft#642 Only add -d once to formatflags (microsoft#644) Updating Changelog and package.json for 0.6.50 update Log errors to console ...
I think a long-term solution would be to import packages normally, without relying on gopkgs (which does not work correctly in this case), and keep them in memory in the long-running process (gocode? Go language server? something new?). And thank you for all your work on this extenstion. I'm in love with it. ❤️ |
Language server is a good idea here. For now, I have a working solution where I am thinking of doing the below
And thanks for your kind words. I'll try and keep up the good work :) |
* Use go list all to get pkgname to use in completions Fixes #647 * Check for version being null * Wait for golist before testing
The fix for this issue is now out in the latest update (0.6.63) to the Go extension Thanks for your patience @AlekSi, I know this took a while :) |
That's a continuation of #613. Get code from https://github.com/AlekSi/vscode-bug and then edit main.go as shown:
Two things are wrong after hitting Enter:
sarama.v1
to code. As I explained in Format removes imports of vendored packages in use #613, the package name issarama
, notsarama.v1
. Package name != last part of import path.vendor/gopkg.in/Shopify/sarama.v1
which is incorrect import path.vendor/
is treated differently by Go toolchain. goreturns does the right thing:The text was updated successfully, but these errors were encountered: