gocode自动补全不起作用。

huangapple go评论79阅读模式
英文:

gocode autocomplete doesn't work

问题

我想使用自动完成,但无法让gocode(https://github.com/nsf/gocode)正常工作。

我选择的编辑器是Brackets(使用https://github.com/David5i6/Brackets-Go-IDE)。但我无法在vim+vundle或komodo中让它正常工作。

  • GO安装时未设置GOPATH
  • 我按照指示设置了GOPATH和PATH,并且可以正常使用go项目。

我的文件夹结构:

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

从我的.profile文件中:

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

使用go env命令,我得到:

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

我在设置上做错了什么吗?或者我可能漏掉了其他什么东西吗?

提前感谢。

英文:

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

答案1

得分: 2

将以下内容添加到您的.profile文件中,然后注销并重新登录:

export GOROOT=/usr/local/go

这样,我就可以在LiteIDE中使用gocode了。

英文:

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.

答案2

得分: 2

经常情况下,gocode是正常工作的,但是编辑器找不到gocode。

测试gocode是否正常工作:
终端1:

  • gocode close
  • gocode -s -debug

终端2:

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

在终端1中查看结果。

如果gocode似乎正常工作:

  • gocode close
  • 启动Brackets,打开一个Go文件。它应该在后台启动gocode。
  • 检查gocode是否在运行:"ps |grep gocode"
  • 如果没有运行,请检查Brackets是否能找到gocode可执行文件。检查路径变量,或者在Brackets配置中添加完整路径。
英文:

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

Test if gocode is working correctly:<br>
<br>
Terminal 1 <br>

  • gocode close
  • gocode -s -debug

<br>
Terminal 2:

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

See results in Terminal 1.
<br>
<br>

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.

huangapple
  • 本文由 发表于 2014年8月17日 03:33:54
  • 转载请务必保留本文链接:https://go.coder-hub.com/25343241.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定