可以在每次重新格式化代码(例如,按 &shortcut:ReformatCode; )时运行 gofmt。第一遍由内置的 GoLand 格式化程序完成,然后由 gofmt 完成。

要启用此功能,请按 &shortcut:ShowSettings; 打开设置,然后导航至 Editor | Code Style | Go 。点击 Other 选项卡并选中 On code reformat 复选框。