J0-nas
J0-nas

Reputation: 95

gocode autocomplete doesn't work

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.

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

Upvotes: 7

Views: 5213

Answers (2)

wlbr
wlbr

Reputation: 147

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.

Upvotes: 2

Shawn Mire
Shawn Mire

Reputation: 306

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.

Upvotes: 2

Related Questions