7

I want to use autocompletion, but can't get gocode (https://github.com/nsf/gocode) working.

The editor of my choice is Brackets (using https://github.com/David5i6/Brackets-Go-IDE). But I can't get it working with vim+vundle or komodo either.

  • The GOPATH wasn't set by the GO installation
  • I set the GOPATH and PATH just like the instruction specified and can work on go projects just fine.

My folder structure:

~/Documents/goDev/bin/
                      test
                      gocode
                 /src/
                     github/
                            jonas/
                                  test/
                                       test.go
                             nfs/
                                  gocode/
                                       ...

From my .profile:

export GOPATH=/Users/jonas/Documents/goDev
export PATH=$PATH:/usr/local/bin:/usr/local/go/bin/:/Users/jonas/Documents/goDev/bin

With go env i get:

...
GOPATH="/Users/jonas/Documents/goDev"
...
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
...

Is there something I did wrong with my setup? Or have I maybe missed something else?

Thanks in advance

Lior Bar-On
  • 10,784
  • 5
  • 34
  • 46
J0-nas
  • 95
  • 2
  • 3

2 Answers2

2

Add the following to your .profile and log out and back in:

export GOROOT=/usr/local/go

This got gocode working for me with LiteIDE.

Shawn Mire
  • 306
  • 2
  • 5
2

Often gocode is working correctly, but the editor does not find gocode.

Test if gocode is working correctly:

Terminal 1

  • gocode close
  • gocode -s -debug


Terminal 2:

  • cd "yourworkspace"
  • gocode -f=json --in=YOURGOFILE.go autocomplete 146

See results in Terminal 1.

If gocode seems to be working:

  • gocode close
  • start Brackets, open a Go file. It should start gocode in the background.
  • Check if gocode is running: "ps |grep gocode"
  • If not - check if Brackets can find the gocode executable. Path var, or add full path to Brackets config.
wlbr
  • 147
  • 1
  • 3