如何在GoClipse中启用自动导入?

030*_*030 1 eclipse import go goclipse

根据这篇文章,可以在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.
Run Code Online (Sandbox Code Playgroud)

问题

当我尝试在Eclipse中搜索Go Formatter时,找不到它。

在此处输入图片说明

boa*_*ter 5

我的眼睛引起注意的一件事:

我知道goimports网址不再是google.com/p/go.tools/cmd/goimports。

因此,请尝试以下操作:

  1. 执行 go get golang.org/x/tools/cmd/goimports
  2. 转到Preferences->Go
  3. 设置gofmt${GOPATH}/bin/goimports(goimports所在的位置)
  4. 重新启动Eclipse并确保goimports在按CTRL+ SHIFT+ 时使用它F

  • @Alfred:您需要“格式化”代码。“单击鼠标右键”-> source-> Go format(gofmt)或`ctr-shift-f`。 (2认同)