Go Formatter formats Go code using goimports or gofmt.

There are three ways to run Go Formatter:

  • On save: When a Go file is saved, it will automatically be formatted
  • Menu item: Select the Editor → Format Go code menu item
  • Command palette: Open the command palette and type Format Go code

Using goimports

To use goimports, it must be installed and visible in your environment (e.g., on your PATH variable). goimports can be installed with this shell command:

$ go install

Using gofmt

To use gofmt:

  1. Uncheck the "Use goimports if available" extension preference
  2. Ensure gofmt is installed (included with the official Go installer) and visible in your environment (e.g., on your PATH variable)


If Go Formatter fails to run, error messages will be shown as a Nova notification. If you run into an issue that you think Go Formatter should handle, please submit a bug report.


Version 0.0.8

Fix bug where format on save was causing dirty buffer

Version 0.0.7

Reduce extension size

Version 0.0.6

Add an extension preference "Format Go files on save" (checked by default) to make it possible to not format on save (but keep the command + menu item functionality).

Version 0.0.5

Add goimports support and make it the new default formatter.

Add an extension preference "Use goimports if available" to control use of goimports vs gofmt.

Version 0.0.4

Allow formatting of non-Go files (e.g., text buffers) with "Format Go code" command and menu item

Version 0.0.3

Clean up documentation

Version 0.0.2

Run gofmt on contents of code buffers, not files

Version 0.0.1

Initial release