You can also define a subset of declarations if you don't want to enforce the order of all of them.
-disable-dec-order-check
-disable-type-dec-order-check
-disable-const-dec-order-check
-disable-var-dec-order-check
-dec-order var,const,func,type
-disable-dec-num-check
-disable-init-func-first-check
You may find the implementation of the rules inside analyzer.go
.
Underscore var declarations can be ignored via -ignore-underscore-vars
.
go install gitlab.com/bosi/decorder/cmd/decorder
You can use the linter via golangci-lint as well: https://golangci-lint.run/usage/linters/#decorder.
# with default options decorder ./... # custom declaration order decorder -dec-order var,const,func,type ./... # disable declaration order check decorder -disable-dec-order-check ./... # disable check for multiple declarations statements decorder -disable-dec-num-check ./... # disable check for multiple declarations (var only) statements decorder -disable-var-dec-num-check ./... # disable check that init func is always first function decorder -disable-init-func-first-check ./... # ignore underscore variables for all checks decorder -ignore-underscore-vars ./...