go - 在 IntelliJ 中保存文件时执行 gofmt

标签 go intellij-idea goland

我将 IntelliJ 与 Golang 插件一起使用。是否可以将 IDE 配置为在文件保存时执行 gofmt?

最佳答案

当然可以。

  1. 安装File Watchers plugin
  2. 打开“Preferences->Tools->File Watchers”并添加一个新的 watcher
  3. 设置File Type:GoProgram:gofmt的绝对路径,Arguments: -w $FilePath$
  4. 点击确定

enter image description here

关于go - 在 IntelliJ 中保存文件时执行 gofmt,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33774950/

相关文章:

intellij-idea - 在 IntelliJ idea 中配置 websphere 时出错

qt - 有效方法以红色高亮显示 'Unresolved Reference'

Goland 无法使用 Go 1.14 识别我的 vendor 目录

Goland 从按钮单击运行/重新运行命令

通过递归调用时 Go-routine 不运行

http - Go Web 服务器不处理 POST 请求

intellij-idea - IntelliJ IDEA 15 "Code > Generate"上下文菜单缺少 "equals() and hashCode()"条目

java - IntelliJ IDEA + Maven 在 iml 文件中需要什么依赖项?

go - 创建没有标题的 zip 文件

algorithm - 根据需要转移值(value)的算法[保留]