如何在 GoClipse 中启用自动导入?
How to enable autoimport in GoClipse?
根据 this post 可以在 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.
问题
当我尝试在 Eclipse 中搜索 Go Formatter 时,我找不到它。
有一件事让我眼前一亮:
我知道 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
并确保它在 CTRL+SHIFT+[=28= 时使用 goimports
]F 被按下。
根据 this post 可以在 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.
问题
当我尝试在 Eclipse 中搜索 Go Formatter 时,我找不到它。
有一件事让我眼前一亮:
我知道 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
并确保它在 CTRL+SHIFT+[=28= 时使用goimports
]F 被按下。