Autocompleting Golang in Atom Text Editor
2 min read.
For a while now I’ve been using Atom as my go to text editor when building stuff for the web. While Apple have the expression “There’s an App for that”, the same could almost be said for Atom in regards to plugins.
At my new workplace we are using Golang for some of the back end services and of course there is a plugin for that! The Go Plus plugin provides everything you need to be effective when writing Go in the Atom Editor.
One thing I had a problem with though is setting up the autocomplete feature that comes with go-plus. This is done by a go package called gocode which checks the content in $GOPATH/pkg
and for me, using gb
as a build tool this was not working correctly.
To fix this I had to update some gocode configuration using gocode set
. I had to set autobuild
, purpose-builtins
to True and because I used gb
, I had to set package-lookup-mode to “gb”.
gocode set propose-builtins true
gocode set autobuild true
gocode set package-lookup-mode gb
After this, things was working a bit better but I still had some issues. I think this is just related to using gb
together with gocode but for some reason autobuild would not work in my project. To solve this I have to periodically run gb build to update $GOPATH/pkg
to make autocompletion work on new code.