Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to get autocomplete in GoClipse

📅 2016-May-13 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ autocomplete, eclipse, go, goclipse, gocode ⬩ 📚 Archive

Problem

I installed the Go compiler and set the GOROOT and GOPATH environment variables correctly. To work with Go files, I installed the GoClipse plugin in Eclipse. When I tried to make Goclipse autocomplete my code, I got this error:

Cannot run program "gocode": error=2, No such file or directory

Solution

The Go compiler is not typically used for autocompletion. There is a separate gocode tool that is used for this purpose. So, to get autocompletion we need to install this by using this command:

$ go get -u github.com/nsf/gocode

I found that this installed the gocode binary in $GOPATH/bin. I opened Window -> Preferences -> Go -> Tools and set this path for gocode. Autocompletion started working immediately after this! 😊

Tried with: GoClipse 0.14.1, Eclipse 4.5.2 and Go 1.6.2


© 2023 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘 Mastodon📧 Email