You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Goland中为所有项目默认启用指定文件监视器?

How to Enable goimports File Watcher by Default for All Projects in GoLand

Hey there! I totally get the annoyance of having to set up the same goimports file watcher for every single new GoLand project—let’s sort this out so you never have to do that manual setup again.

Here’s the step-by-step to set it as a default for all new projects:

  • Open GoLand’s global default settings:
    • If you’re in an existing project, go to File > New Projects Setup > Settings for New Projects
    • If you’re on the welcome screen, click Configure > Settings for New Projects
  • In the settings window, navigate to Tools > File Watchers
  • Click the + button in the top-right corner to add a new watcher, then select goimports from the list (if it’s not there, you can choose Custom and set it up manually)
  • Configure the watcher details to match your needs (here’s the standard setup that works for most folks):
    • Program: Make sure this points to your installed goimports binary. If GoLand doesn’t auto-detect it, you can manually set the path (e.g., $GOPATH/bin/goimports or the full path like /Users/yourname/go/bin/goimports)
    • Arguments: Use -w $FilePath$ (this tells goimports to write changes directly to the file)
    • Working directory: Set to $FileDir$
    • Output paths to refresh: Enter $FilePath$
    • Don’t forget to check the box for Auto-save edited files to trigger the watcher if you want it to run automatically when you change a file
  • Click Apply then OK to save these default settings

From now on, every new project you create in GoLand will have the goimports file watcher enabled right out the gate.

Quick note for existing projects:

If you already have projects that need this watcher, you can export the configuration from one project (File > Export Settings, select File Watchers) and import it into others (File > Import Settings). Alternatively, if you use GoLand’s Settings Repository feature, you can sync your file watcher settings across all your projects automatically.

Also, double-check that goimports is installed on your system—if not, run this command in your terminal:

go install golang.org/x/tools/cmd/goimports@latest

内容的提问来源于stack exchange,提问作者Duncan Jones

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 07:35:20