Intellij自动优化Go的导入

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

Intellij auto optimize imports for Go

问题

我有Intellij的终极版本14.1.4。如何在保存时自动启用优化导入功能,针对"Go"语言?在"设置->编辑器->常规->自动导入"中,我看到了Java/Python/Scala的选项,但没有"Go"的选项。我已经安装了Go插件。但这个未使用的导入编译错误很烦人。我想启用自动优化导入以避免使用"CTRL+ALT+O"组合键。

英文:

I have Intellij ultimate version 14.1.4. How do I enable optimizing imports automatically with each save for "Go"? <br>In Settings->Editor->General->Auto Imports, I see options for Java/python/scala but not for Go. I have the Go plugin installed already. But this unused import compile error is a noise. I want to enable automatic optimizing of imports to avoid CTRL+ALT+O combination

答案1

得分: 2

这个功能目前还不适用于Go插件,所以你在那里看不到任何选项,也不能自动工作。

你可能想要关注这个问题或者这个PR,以便在它们被修复时收到通知。

与此同时,你可以使用Code -> Goimports file功能,并可能为其分配一个你自己喜欢的快捷键,因为默认情况下它没有快捷键。为了使其工作,你需要安装并将goimports添加到系统的PATH中。

英文:

This functionality is not yet available for the Go plugin, that's why you don't see any options there / it doesn't work automatically.

You might want to watch this issue or maybe this PR to get notified when they will be fixed.

Meanwhile, you can use the Code -> Goimports file functionality and maybe assign it a shortcut of your own preference as it doesn't have one by default. For this to work you will need to have goimports installed and in your system's PATH.

huangapple
  • 本文由 发表于 2015年12月29日 02:13:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/34498566.html
匿名

发表评论

匿名网友

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

确定