gosrt
gosrt sorts top-level symbols in Go code.
âš gosrt is still in early development. It might work, it might destroy your
code! Only use it on code under version control.
The order is the same as that of godoc, i.e:
- Package declarations, imports, ‘loose’ comments
- Constants
- Variables
- Functions (except constructors), alphabetically
- Types:
- Type declaration
- Constructors, alphabetically
- Methods, alphabetically
💾 Installation
go install gitlab.com/biffen/gosrt@latest
⌨ Usage
See usage.txt.
Example
package example
func Zebra() { /* … */ }
func NewOcelot() (*Ocelot, error) { /* … */ }
type Ocelot struct { /* … */ }
func (o *Ocelot) Close() error { /* … */ }
var (
global = 42
)
func Albatross() { /* … */ }
func (o *Ocelot) String() string { /* … */ }
gosrt -w example.go
package example
var (
global = 42
)
func Albatross() { /* … */ }
func Zebra() { /* … */ }
type Ocelot struct { /* … */ }
func NewOcelot() (*Ocelot, error) { /* … */ }
func (o *Ocelot) Close() error { /* … */ }
func (o *Ocelot) String() string { /* … */ }
🪲 Bugs
If you find a bug don’t be surprised. But please report it at
https://gitlab.com/biffen/gosrt/issues.
License
gosrt is licensed under the MIT license.