Skip to content
This repository

An autocompletion daemon for the Go programming language

Octocat-spinner-32 _gccgo Run `go fmt` on `_gccgo/package.go`. April 10, 2014
Octocat-spinner-32 _goremote Move things again, trying to suit GOPATH scheme. March 19, 2012
Octocat-spinner-32 _testing Rename test input files. April 10, 2014
Octocat-spinner-32 debian Remove 'goremote' from 'rules', it's for internal use only. August 08, 2011
Octocat-spinner-32 docs Add a header to docs for server-side -debug mode section. March 27, 2014
Octocat-spinner-32 emacs-company emacs-company: Make showing annotation optional February 21, 2014
Octocat-spinner-32 emacs Allow emacs to exit when gocode binary cannot be found March 17, 2014
Octocat-spinner-32 vim Can't set system function name to lower letter variables. gocomplete#… March 14, 2014
Octocat-spinner-32 .gitignore Radical change. Move towards goinstall compatibility. December 26, 2011
Octocat-spinner-32 LICENSE Add LICENSE. Gocode has MIT license. August 19, 2010
Octocat-spinner-32 Add instructions for Vim plugin installation using Vundle April 16, 2014
Octocat-spinner-32 autocompletecontext.go Merge branch 'typo' of April 09, 2014
Octocat-spinner-32 autocompletefile.go Use build.Context instead of gocode_env. April 06, 2014
Octocat-spinner-32 client.go Use build.Context instead of gocode_env. April 06, 2014
Octocat-spinner-32 config.go add "autobuild" option (no-op for now) April 13, 2014
Octocat-spinner-32 cursorcontext.go Log extracted expression tokens. April 10, 2014
Octocat-spinner-32 decl.go Fix infinite recursion cases in advance_to_* functions. Fixes #168. November 22, 2013
Octocat-spinner-32 declcache.go Replace \"%s\" with %q. Handly Go's printf feature. April 17, 2014
Octocat-spinner-32 formatters.go Fix docs and code regarding default formatter. December 23, 2013
Octocat-spinner-32 gocode.go Add http handler for profiling April 13, 2014
Octocat-spinner-32 os_posix.go Introduce config_dir(), move both to os_ specific files. December 26, 2012
Octocat-spinner-32 os_windows.go Windows-specific config_dir/config_file implementation. December 26, 2012
Octocat-spinner-32 package.go Fix packages parser after Go's 18248 changeset. Closes #163. October 05, 2013
Octocat-spinner-32 ripper.go Big refactoring, CamelCase -> words_with_underscores. February 25, 2012
Octocat-spinner-32 rpc.go Use build.Context instead of gocode_env. April 06, 2014
Octocat-spinner-32 scope.go Big refactoring, CamelCase -> words_with_underscores. February 25, 2012
Octocat-spinner-32 server.go Misc improvements for -debug logging. April 17, 2014
Octocat-spinner-32 utils.go Use case-insensitive filtering as a fallback, if no proposals were fo… September 04, 2012

An autocompletion daemon for the Go programming language

Gocode is a helper tool which is intended to be integrated with your source code editor, like vim and emacs. It provides several advanced capabilities, which currently includes:

  • Context-sensitive autocompletion

It is called daemon, because it uses client/server architecture for caching purposes. In particular, it makes autocompletions very fast. Typical autocompletion time with warm cache is 30ms, which is barely noticeable.

Also watch the demo screencast.

Gocode in vim

Gocode in emacs


  1. You should have a correctly installed Go compiler environment and your personal workspace ($GOPATH). If you have no idea what $GOPATH is, take a look here. Please make sure that your $GOPATH/bin is available in your $PATH. This is important, because most editors assume that gocode binary is available in one of the directories, specified by your $PATH environment variable. Otherwise manually copy the gocode binary from $GOPATH/bin to a location which is part of your $PATH after getting it in step 2.

    Do these steps only if you understand why you need to do them:

    export GOPATH=$HOME/goprojects

    export PATH=$PATH:$GOPATH/bin

  2. Then you need to get the appropriate version of the gocode, for 6g/8g/5g compiler you can do this:

    go get -u (-u flag for "update")

    Windows users should consider doing this instead:

    go get -u -ldflags -H=windowsgui

    That way on the Windows OS gocode will be built as a GUI application and doing so solves hanging window issues with some of the editors.

  3. Next steps are editor specific. See below.

Vim setup

Manual installation

In order to install vim scripts, you need to fulfill the following steps:

  1. Install official Go vim scripts from $GOROOT/misc/vim. If you did that already, proceed to the step 2.

  2. Install gocode vim scripts. Usually it's enough to do the following:

    2.1. vim/ script does the following:

    mkdir -p "$HOME/.vim/autoload"
    mkdir -p "$HOME/.vim/ftplugin/go"
    cp "${0%/*}/autoload/gocomplete.vim" "$HOME/.vim/autoload"
    cp "${0%/*}/ftplugin/go/gocomplete.vim" "$HOME/.vim/ftplugin/go"

    2.2. Alternatively, you can create symlinks using script in order to avoid running after every gocode update. script does the following:

    cd "${0%/*}"
    mkdir -p "$HOME/.vim/autoload"
    mkdir -p "$HOME/.vim/ftplugin/go"
    ln -s "$ROOTDIR/autoload/gocomplete.vim" "$HOME/.vim/autoload/"
    ln -s "$ROOTDIR/ftplugin/go/gocomplete.vim" "$HOME/.vim/ftplugin/go/"
  3. Make sure vim has filetype plugin enabled. Simply add that to your .vimrc:

    filetype plugin on

  4. Autocompletion should work now. Use <C-x><C-o> for autocompletion (omnifunc autocompletion).

Using Vundle

Add the following line to your .vimrc:

Plugin 'nsf/gocode', {'rtp': 'vim/'}

And then update your packages by running :PluginInstall.


Alternatively take a look at the vundle/pathogen friendly repo:

Emacs setup

In order to install emacs script, you need to fulfill the following steps:

  1. Install auto-complete-mode

  2. Copy emacs/go-autocomplete.el file from the gocode source distribution to a directory which is in your 'load-path' in emacs.

  3. Add these lines to your .emacs:

    (require 'go-autocomplete)
    (require 'auto-complete-config)

Also, there is an alternative plugin for emacs using company-mode. See emacs-company/README for installation instructions.


You can change all available options using gocode set command. The config file uses json format and is usually stored somewhere in ~/.config/gocode directory. On windows it's stored in the appropriate AppData folder. It's suggested to avoid modifying config file manually, do that using the gocode set command.

gocode set lists all options and their values.

gocode set <option> shows the value of that option.

gocode set <option> <value> sets the new value for that option.

  • propose-builtins

    A boolean option. If true, gocode will add built-in types, functions and constants to an autocompletion proposals. Default: false.

  • lib-path

    A string option. Allows you to add search paths for packages. By default, gocode only searches $GOPATH/pkg/$GOOS_$GOARCH and $GOROOT/pkg/$GOOS_$GOARCH in terms of previously existed environment variables. Also you can specify multiple paths using ':' (colon) as a separator (on Windows use semicolon ';').

  • autobuild

    A boolean option. If true, gocode will try to automatically build out-of-date packages when their source files are modified, in order to obtain the freshest autocomplete results for them. Default: false.


If something went wrong, the first thing you may want to do is manually start the gocode daemon in a separate terminal window. It will show you all the stack traces and panics if any. Shutdown the daemon if it was already started and run a new one explicitly:

gocode close

gocode -s

Please, report bugs, feature suggestions and other rants to the github issue tracker of this project.


There is Guide for IDE/editor plugin developers.

If you have troubles, please, contact me and I will try to do my best answering your questions. You can contact me via email. Or for short question find me on IRC: #go-nuts @ freenode.


  • It's a good idea to use the latest git version always. I'm trying to keep it in a working state.
Something went wrong with that request. Please try again.