Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gocode external package give no suggestion for vscode

My auto-complete / intellisense stopped working after upgrading from the Go extension here of Visual Studio Code: https://github.com/microsoft/vscode-go

I've opened an issue in there, but I'm thinking this might have to do with gocode.

I'm running Windows 10, Go version 1.5.1, Visual Studio Code 0.10.5 and Go extension 0.6.21. Was working fine before updating and I was using Go extension 0.6.17.

Problem is suggestions / intellisense works for internal package, but every external package I have no longer give suggestions when writing . or ctrl+space. Even net/http or core Go package does not work.

I wanted to try and run gocode myself to see what it's actually returning, so I've looked into the code for the extension and it is executing a child process similar to that: gocode -f=json autocomplete filename offset.

Not really sure how to get offset or what it represents, number of bytes for position that triggers the auto-complete? In any case, when I run this I got no output and I do not return to the prompt, I have to CTRL+C to return.

I'm unable to find anything interesting on Google either, probably wrongly searching or not exactly knowing what to search for.

Does someone would have an idea, goal of running gocode was to see if in fact the gocode was returning suggestion for external package than if yes, there's something with the extension.

If gocode does not returns anything, well it means it's not working properly now, anything I can do?

Thanks

Edit 1: Log from gocode following kostya answer

2015/12/23 07:26:11 Import path "github.com/gocraft/web" was not resolved 2015/12/23 07:26:11 Gocode's build context is: 2015/12/23 07:26:11 GOROOT: c:\go 2015/12/23 07:26:11 GOPATH: 2015/12/23 07:26:11 GOOS: windows 2015/12/23 07:26:11 GOARCH: amd64 2015/12/23 07:26:11 GBProjectRoot: "" 2015/12/23 07:26:11 lib-path: ""

It seems my GOPATH variable is not evaluated, but it's set, and when I run echo %GOPATH% I receive the correct value.

like image 472
Dominic St-Pierre Avatar asked Dec 22 '15 20:12

Dominic St-Pierre


1 Answers

Try running gocode server process in the console and observe the output:

gocode close
gocode -debug -s

Make sure that you are running the latest version of gocode:

go get -u github.com/mdempsky/gocode

You might want to run the following command to build gocode instead (though I believe you won't be able to use debug method that I suggested in this case):

go get -u -ldflags -H=windowsgui github.com/mdempsky/gocode

as suggested at https://github.com/mdempsky/gocode

like image 184
kostya Avatar answered Nov 13 '22 23:11

kostya