Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

can't autoimport packages in vendor directories #1147

Closed
Hawken94 opened this issue Aug 17, 2017 · 19 comments
Closed

can't autoimport packages in vendor directories #1147

Hawken94 opened this issue Aug 17, 2017 · 19 comments

Comments

@Hawken94
Copy link

I use glide and find that vscode can't autoimport packages in vendor directories . But it can autoimport packages in $GOPATH/src . I don't know the reason . Sorry for my bad english.

@airlanggacahya
Copy link

Try to restart vs-code after running glide. Maybe related to #1146

@Hawken94
Copy link
Author

@airlanggacahya I try it but it doesn't work ( in my windows10) . I remember I can auto-import packages in vendor directories in my ubuntu 16 . I will try it on my ubuntu after I get back home at night .May it isn't a big problem . PS , it can auto-import packages in vendor directories when I use Gogland .

@Hawken94
Copy link
Author

@airlanggacahya I tried . It can work on ubuntu 16.

@ramya-rao-a
Copy link
Contributor

@Hawken94 Do you still see this issue in Windows?

When you say auto-import, are you referring to adding the missing import statements when you format the file or save the file?

@Hawken94
Copy link
Author

@ramya-rao-a No, when I use the package(method) at the first time, vs code can't auto-import it's package in win10. Normally, when I write "println", it will import fmt package automatically. Sorry for my bad english again. But it can work in ubuntu 16. I don't know the reason.

@ramya-rao-a
Copy link
Contributor

@Hawken94 We have made some changes around completions for unimported packages. Can you try out the latest Go extension from source and see if that helps?

@Hawken94
Copy link
Author

Hawken94 commented Oct 2, 2017

@ramya-rao-a OK,I will try it now. Thank vs code! Thank Microsoft! Thank you for solving my problem.

@Hawken94
Copy link
Author

Hawken94 commented Oct 2, 2017

@ramya-rao-a Sorry, I took some time to try, but it still dosen't work. It is OK, I almost work on ubuntu16, so it's not a trouble. Thank you again! (windows 10 1703, vs code 1.16.1, go 1.9 ) This issue can be closed.

  • I describe my problem again. When I glide init and glide get github.com/skip2/go-qrcode (e.g.) , I write "qrcode", the vscode didn't prompt and import the package. This is my problem. But in ubuntu, it has a nice prompt and will auto-import the package just like the built-in package.
  • Thank you again! I can write import "github.com/skip2/go-qrcode" manually, so it's not a big problem.
    sorry for my bad english. I can say Chinese if necessary.
    This is my glide.yaml: (just for testing)

package: littlezz
import:

  • package: github.com/skip2/go-qrcode
  • package: github.com/gorilla/mux
    version: ^1.5.0

@ramya-rao-a
Copy link
Contributor

@Hawken94 Your English is fine, dont worry about it :)

But in ubuntu, it has a nice prompt and will auto-import the package just like the built-in package.

What prompt are you talking about here? Can you share a screenshot? Do you mean auto-completion?

Can you check your settings? Do you have go.autocompleteUnimportedPackages enabled in either ubuntu or windows?

@Hawken94
Copy link
Author

Hawken94 commented Oct 4, 2017

@ramya-rao-a Thank you for your praise!

This is in Ubuntu 16. Firstly,

default
Secondly, when I write "qrcode", vscode has a nice prompt. And then I press the Enter key, it auto-import the 'qrcode' package.
default
default

This is in Windows 10. The version of vscode-go is 0.6.66. I just upgrade it.

The setting is OK.
win_1
It doesn't work in windows 10.
win_2
As usual, it can auto-import the built-in packages and packages in GOPATH.
win_3

  • This is my test. I don't know what will happen in your windows 10. If you can recurrent my issues, it can't be better.
  • My gmail account is [email protected]. If you have other problem to ask, please contact with me.
  • Happy mid-Autumn Festival!

@ramya-rao-a
Copy link
Contributor

Can you run Go: Browse Packages or Go: Add Import command and see if qrcode appears in the list?

@Hawken94
Copy link
Author

Hawken94 commented Oct 5, 2017

@ramya-rao-a When I run Go: Browse Packages command, 'qrcode' appears in the list. But Go: Add Import doesn't.

@ramya-rao-a
Copy link
Contributor

Alright, I have a fix in.

Can you try the below to see if my fix works for you?

@Hawken94
Copy link
Author

Hawken94 commented Oct 5, 2017

@ramya-rao-a I had a try just now. It has a nice prompt. It works. Thank you very much!!!

@ramya-rao-a
Copy link
Contributor

No problem, thanks for reporting the issue and Happy Coding!

@Hawken94
Copy link
Author

@ramya-rao-a I find another problem today. The functions or interfaces can't go to definition if they are in vendor directory .
tim 20171012104425
tim 20171012104508

@ramya-rao-a
Copy link
Contributor

@Hawken94 that would be a separate issue. Try setting go.docsTool to gogetdoc in your settings

@Hawken94
Copy link
Author

@ramya-rao-a When I set go.docsTool to gogetdoc, it can go to definition.But there is another question. When my mouse on the function, it can't show the definition.
Packages in GOPATH can show :):
image

It doesn't work.
image

Thanks all the way. I think it is not a big problem ^_^

@ramya-rao-a
Copy link
Contributor

@Hawken94 Try running gogetdoc from the command line/terminal. If you don't get the docs as expected, then log an issue at https://github.com/zmb3/gogetdoc

@vscodebot vscodebot bot locked and limited conversation to collaborators Jan 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants