sorted is a linter and formatter used to maintain consistent sorting across various structures.
At the moment it only supports alphabetic sorting in const, var and
struct blocks, but we're aiming to support any kind of sortable or
order-related structures like generics, func in/out arguments and more.
It can be generalized into 2 main categories for now, that are
-
Blocks
const ( // or var B = iota // B, A are not sorted alphabetically A )
-
Multiple sections treated as such
const ( // or var B = iota // B, A are not sorted alphabetically A C // ok D Z // Z, Y are not sorted alphabetically Y X )
-
Multiple inline identifiers
const c, b, a = 0, 0, 0 // single line idents are not sorted alphabetically
These checks are working for const, var, struct blocks.
-
const,var- Blocks
- Alphabetical sorting
- Auto Fix
- Inline
- Alphabetical sorting
- Auto Fix
- Blocks
-
struct- Alphabetical sorting
- Auto Fix
-
//sorted:ignorecomment
in order of most importance
-
golangci-lintintegration -
switchonly for basic type values (string, int, ...) -
imports(pretty much what gci does with some more) -
func- Alphabetical sorting
- Public/Private sorting
New*func order
- Generics