Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gocode autocomplete doesn't work

Tags:

ide

go

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

like image 691
J0-nas Avatar asked Aug 16 '14 19:08

J0-nas


2 Answers

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.

like image 54
Shawn Mire Avatar answered Nov 11 '22 21:11

Shawn Mire


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.
like image 24
wlbr Avatar answered Nov 11 '22 23:11

wlbr