英文:
How to enable autoimport in GoClipse?
问题
根据这篇帖子,可以在GoClipse中启用自动导入功能:
-
安装goimports:
go get code.google.com/p/go.tools/cmd/goimports -
在Eclipse中转到:Preferences -> Go -> Go Formatter,并将其设置为goimports二进制文件的路径
这样,在格式化代码时会修复所有的导入问题。如果结合使用#67,保存时导入将自动修复。
问题
当我尝试在Eclipse中搜索Go Formatter时,找不到它。
英文:
According to this post autoimport could be enabled in GoClipse:
> 1) install goimports:
> go get code.google.com/p/go.tools/cmd/goimports
>
> 2) in eclipse goto: Preferences -> Go -> Go Formatter and set it to be the path of the goimports bin
>
> This will fix all imports when you format. If you combine this with #67, then imports will be automatically fixed on save.
Problem
When I try to search for Go Formatter in Eclipse I cannot find it.
答案1
得分: 5
我注意到一件事:
我知道 goimports 的 URL 不再是 google.com/p/go.tools/cmd/goimports。
所以让我们尝试以下步骤:
- 执行
go get golang.org/x/tools/cmd/goimports
- 进入
Preferences
->Go
- 将
gofmt
设置为${GOPATH}/bin/goimports
(goimports 的位置) - 重新启动
Eclipse
并确保在按下<kbd>CTRL</kbd>+<kbd>SHIFT</kbd>+<kbd>F</kbd>时使用goimports
。
英文:
One thing that my eyes caught out:
I know that goimports URL is no longer google.com/p/go.tools/cmd/goimports.
So lets try the following:
- Execute
go get golang.org/x/tools/cmd/goimports
- Go to
Preferences
->Go
- Set
gofmt
to${GOPATH}/bin/goimports
(which is where goimports is located) - Restart
Eclipse
and make sure it usesgoimports
when <kbd>CTRL</kbd>+<kbd>SHIFT</kbd>+<kbd>F</kbd> is pressed.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论