This is a simple linter which is designed to report upon functions which are not implemented in alphabetical order within files.
The motivation behind this tool was twofold:
- I find it easier to navigate functions if they are ordered alphabetically.
- Most IDEs offer a tree/outline view which is ordered alphabetically, and the contents and the tree should match!
- Once I realized a linter, driven by "
go vet
", could be named "alphavet" I couldn't resist the temptation to hack it up.- Even though this could just has easily have been a portable Perl script.
If you have a working golang toolset you should be able to install by:
go install github.com/skx/alphavet/cmd/alphavet@latest
The linter is designed to be driven by go vet
like so:
$ go vet -vettool=$(which alphavet) ./...
By default the two functions init
and main
are excluded from the alphabetical ordering requirement. If you wish to exclude additional functions you may do so, via the -exclude
parameter:
$ go vet -vettool=$(which alphavet) -exclude=init,main,New ./...
Sample output would look something like this:
$ go vet -vettool=$(which alphavet) ./...
# github.com/skx/gobasic/builtin
./builtin.go:67:1: function Get should have been before Register
./misc_test.go:21:1: function LineEnding should have been before StdInput
./misc_test.go:29:1: function StdError should have been before StdOutput
./misc_test.go:33:1: function Data should have been before StdError
This repository is configured to run tests upon every commit, and when pull-requests are created/updated. The testing is carried out via .github/run-tests.sh which is used by the github-action-tester action.
Please do feel free to report any issues you see with the code, or the results.
Feature requests are also welcome, although I'd prefer to avoid having excessive flags.