a Go formatter for those very particular about ordering.
Most of us who use Go like to structure their files in the following format:
package ...
import ...
const ...
var ...
type ...
func ...
This is exactly what go-order
does! I originally implemented this idea
in go-order.nvim, a Lua NeoVim
extension that uses Treesitter. I wanted this to be more widely available to allow others
who do not use Neovim to benefit from this, hence the rewrite.
To install, simply:
go install github.com/td0m/go-order@latest
To sort the file and print the output to stdout:
go-order -a < main.go
For help:
go-order -h
The following features are still in consideration:
- sorting inside of const, var, and type blocks
- sorting struct fields