gocode
gocode copied to clipboard
gocode.exe not working on Windows 10
Hi.
I am developing in go under Ubuntu but at home I wanted to give it a try on my home Windows machine. It seems everything is working properly except gocode.exe - running any of gocode.exe set
, gocode.exe set autobild
, ``gocode.exe set autobild true` nor the autocompletion for go work (no output at all for commands in console nor in console running as administrator). I tried running them in cmd.exe as well as in PowerShell (and PowerShell Administrator ISE) - no luck getting any output nor autocompletion (in Atom) to work.
Windows 10, 64 bit, Go 1.7 (after running go version
in cmd got this output go version go1.7 windows/amd64
).
One weird thing I have just now experienced:
- I navigated to
c:\gowork\github.com\nsf\gocode
- I ran
go build
andgo install
- then after running
gocode set
I finally got some output - then I
cd c:\gowork\
andgocode set
is again not working... WTF?!
Is C:\gowork\bin in your PATH environment variable?
Of course it is. Running PATH
in cmd returns me my PATH with c:\gowork\bin
included.
I don't know here, hard to tell what's going on.
@nsf Same issue for me, Win 10 64 bit, Go 1.7.1. I can get auto completion to work occasionally but the performance is unreliable. No log with any gocode commands and have everything correct in my path.
I'll try it on windows 10 tomorrow.
Installed Go 1.7.1 on my windows 10 machine (official Go installer), it added GOROOT env var and modified PATH env var.
Installed Git 2.1.0 (official installer), asked it to expose itself on PATH.
Added GOPATH env var pointing to C:\waytogo.
go get github.com/nsf/gocode
go get github.com/nsf/godit
Tried editing files in godit, autocompletion works perfectly, haven't noticed any lags.
Could you guys try editing stuff in godit? It's a simple emacs-like text editor written by me, it works on windows just fine. Just open some random Go file in it (godit file.go
), make sure it's saved on disk (otherwise gocode won't be triggered), and use Ctrl-x Ctrl-a for autocompletion. Ctrl-x Ctrl-c for exit.
If it works well in godit, then text editors are to blame. Godit can be seen as a reference gocode integration.
Oh, just wanted to add. My windows 10 has automatic updates disabled, hence its state may not match yours. So, there is a chance that some windows 10 update breaks things, but it seems unlikely.
I will try goedit later today if I have time. @shadyyx Removing a factor hopefully, don't have avast slowing down your gocode do you?
It works fine here on Windows 10 (using it with VSCode) but the performance is atrocious (a few seconds for code completion). Running gocode in debug mode I noticed that all packages are rebuilt every single time a request comes in o_O This is something I noticed with go build if you don't use -i. @nsf any clues on what might be happening?
Gocode's "autobuild" feature is experimental and have never been tested properly. Maybe for some reason it fails on windows. Unless vscode forces it on, I recommend disabling it.
@nsf VSCode doesn't do anything special, it starts the process and exposes it on a TCP socket, then spawns a new process to ask for auto completion of the file at a specific cursor position.
How can I try to disable that feature to see if it helps?
Well, in this case autobuild should be disabled by default. You need to find the gocode binary and exec it via cmd.exe or something. gocode set
will print the gocode config. There make sure autobuild
is set to false. If it is, then it's not gocode who's building stuff. Also keep in mind that third party plugins may invoke third party tools and who knows maybe it's not gocode's fault.
gocode.exe set
propose-builtins true
lib-path ""
custom-pkg-prefix ""
custom-vendor-dir ""
autobuild true
force-debug-output ""
package-lookup-mode "go"
close-timeout 1800
unimported-packages false
Autobuild is set to true o_O
This is how I started gocode: gocode.exe -s -sock tcp -addr 127.0.0.1:37373
VSCode spawns a process and send a command similar to gocode.exe -f=json autocomplete "c:\Users\Matt\Go\src\github.com\pkg\my_file.go" c4706
Vscode plugin might invoke "set" command and set it to true. Find a way to force it to false. Plugin should be open source. gocode set autobuild false
will set it to false, I don't remember where gocode's config is on windows. Somewhere in there: https://github.com/nsf/gocode/blob/master/os_windows.go#L40-L48
I did find out that the VSCode Go extension does have a flag to autobuild:
let gocode = getBinPath('gocode');
let autobuild = vscode.workspace.getConfiguration('go')['gocodeAutoBuild'];
cp.execFile(gocode, ['set', 'propose-builtins', 'true'], {}, (err, stdout, stderr) => {
cp.execFile(gocode, ['set', 'autobuild', autobuild], {}, (err, stdout, stderr) => {
resolve();
});
});
I'll turn that off this way (in the config) and confirm that it fast again. Funny enough this feature works well on Mac but I'll investigate that separately.
I think the feature invokes the go tool. So if you have some unconventional setup or something it might fail. Also I believe go tool uses modification timestamps to rebuild out of date things. Not sure how well it would work on windows. On linux and mac it's solid because timestamps were used by "make" for ages.
I can confirm that when turning off this feature it is fast again. The VSCode Go extension have that feature turned on by default, probably because most extension developers are on unix systems.
I'll look at what gocode/go tool does to determine if the packages should be rebuilt. I've only recently started developing on Windows from time to time and I did notice that go build
recompiles everything if I don't use the -i
flag. So there might be a simple workaround.
Thanks again for gocode, it's a very convenient tool I rely on daily :)
go build
should not be used most of the time. Gocode's autobuild feature runs go install
. go build
is useless because it's a blank build, it does nothing. go install
builds and saves binaries.
Code for reference: https://github.com/nsf/gocode/blob/master/declcache.go#L189-L252
It's a very simple feature.
perfect, I'll investigate and see what's causing the issue under Windows.
After further investigation... I have no idea what was wrong. I removed the executable, added some debug statements, rebuilt it and copied it (for some reason go install wasn't moving the file properly). After that, autobuild worked as expected on Windows 10, VSCode, autobuild on, Go 1.8. I can only assume something was wrong with my system and my coworkers.