如何在 GoClipse 中进行交叉引用?

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

How to cross-reference in GoClipse?

问题

我昨天在我的Macbook上安装了Eclipse(Mars)和Goclipse插件。它们最初运行得很完美。但是今天我发现我无法进行交叉引用(也就是说,无法通过cmd+单击关键字跳转到定义)。控制台显示如下:

运行中:oracle -pos=/Users/myname/coreos/naas/server/src/mycompany.com/hh/naas-server/main.go:#389,#389
-format=json describe mycompany.com/hh/naas-server
失败:无法启动进程:
原因:无法运行程序"oracle":错误=2,没有这个文件或目录

英文:

I have installed Eclipse (Mars) with Goclipse plugin on my Macbook yesterday. They initially work perfectly. But today I found I cannot do cross reference (that means cmd+click on a keyword cannot jump the definition). And the console shows:

> Running: oracle -pos=/Users/myname/coreos/naas/server/src/mycompany.com/hh/naas-server/main.go:#389,#389
> -format=json describe mycompany.com/hh/naas-server
> FAILED: Could not start process:
> Reason: Cannot run program "oracle": error=2, No such file or directory

答案1

得分: 7

如Voker建议的那样,GoClipse只是一个Eclipse插件。为了编译、构建和运行你的Go包和应用程序,它需要Go工具。

你可以在设置页面上设置标准的Go工具:

窗口 -> 首选项 -> Go

你可以在页面上设置一些非标准的、不同的Go工具:

窗口 -> 首选项 -> Go -> 工具

这里你可以告诉GoClipse你的oracle和gocode程序的位置。

你必须自己下载oracle,但上面的设置页面提供了一个按钮:

<kbd>下载Go oracle(运行:`go get -u golang.org/x/tools/cmd/oracle`)</kbd>

所以你要么手动go get它,要么使用上面提到的按钮。使用go install安装它,这样你就会得到可执行的二进制文件oracle。你必须在Go -> 工具设置页面上设置oracle的完整路径,它就会工作。

顺便说一下:我还建议你安装gocode(https://github.com/nsf/gocode),它将为你提供自动完成功能(<kbd>CTRL+SPACE</kbd>或<kbd>CMD+SPACE</kbd>显示包中导出的标识符列表、方法列表等)。只需在同一设置页面上使用按钮:

<kbd>下载gocode(运行:`go get -u github.com/nsf/gocode`)</kbd>

安装它并设置结果可执行二进制文件gocode的完整路径。

英文:

As Voker suggested, GoClipse is just an Eclipse plugin. For it to compile, build, run your Go packages and applications, it requires the Go tools.

You can set the standard Go tool on the settings page:

Window -&gt; Preferences -&gt; Go

You can set some non-standard, differnet Go tools on the page:

Window -&gt; Preferences -&gt; Go -&gt; Tools

This is where you can tell GoClipse where your oracle and gocode programs are located.

You have to download oracle yourself, but the settings page above provides you a button:

<kbd>Download Go oracle (run: `go get -u golang.org/x/tools/cmd/oracle`)</kbd>

So you have to go get it either manually or by the above-mentioned button. Install it using go install, so you will have the executable binary oracle. You have to set the full path of oracle on the Go -&gt; Tools settings page, and it will work.

While we're at it: I also recommend you to install gocode (https://github.com/nsf/gocode) which will provide you the auto-complete feature (<kbd>CTRL+SPACE</kbd> or <kbd>CMD+SPACE</kbd> for a list of exported identifiers in package, list of methods etc.). Just also use the button on the same settings page:

<kbd>Download gocode (run: `go get -u github.com/nsf/gocode`)</kbd>

Install it and set the full path of the resulted executable binary gocode.

huangapple
  • 本文由 发表于 2015年9月2日 16:03:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/32347729.html
匿名

发表评论

匿名网友

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

确定