On my Linux, just after upgrading Go to version 1.9, I lost autompletion functionality in VS Code.
:vscode_completion_not_working
This tip did not work for me.
So let’s try to debug it.
First, we close the auto-completion server (see github.com/nsf/gocode ) :
1gocode close
2killall gocode
Then we relaunch it as a server in debug mode inside a console :
1gocode -debug -s
So now, we can see what’s happening.
OK, time to try an auto-completion inside VS Code.
Bingo ! We got some useful log :
12018/03/26 23:27:32 Import path "net/http" was not resolved
22018/03/26 23:27:32 Gocode's build context is:
32018/03/26 23:27:32 GOROOT: /usr/local/go
42018/03/26 23:27:32 GOPATH: /home/barim
52018/03/26 23:27:32 GOOS: linux
62018/03/26 23:27:32 GOARCH: amd64
72018/03/26 23:27:32 BzlProjectRoot: ""
82018/03/26 23:27:32 GBProjectRoot: ""
92018/03/26 23:27:32 lib-path: ""
102018/03/26 23:27:32 Error parsing input file (inner block):
112018/03/26 23:27:32 3:6: expected selector or type assertion, found ';'
12...
Weird, my GOROOT isn’t at /usr/local/go but at /usr/lib/go.
It seems like gocode doesn’t care about my env and arbitrary choose to look inside this folder.
Ok, let’s trick him with a symlink :
1sudo ln -s /usr/lib/go /usr/local/go
Now it works !