- Go Formatter
- Formats Go code using goimports or gofmt
- 646 Installs
-
This extension is allowed to:
- Read Files
- Launch Subprocesses
Readme
Go Formatter for Nova
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 golang.org/x/tools/cmd/goimports@latest
Using gofmt
To use gofmt
:
- Uncheck the
"Use goimports if available"
extension preference - Ensure
gofmt
is installed (included with the official Go installer) and visible in your environment (e.g., on yourPATH
variable)
Issues
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.
Install
Go Formatter at Nova's Extension Library
Or, install using Nova by selecting Extensions → Extension Library..., searching for Go Formatter, and clicking the Install button.
Changelog
Version 0.0.10
Update readme
Version 0.0.9
Internal changes: Simplify extension development
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
License
MIT License
Copyright (c) 2022 Jeremy Brudvik
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.