This repositoriy contains a custom Go vet tool
that implements checkers for common mistakes in
Dogma application and message handler
implementations.
Installation
GO111MODULE=off go get -u github.com/dogmatiq/dogmavet/...
Visual Studio Code
Assuming your GOROOT
is in the default location, simply update the
go.vetFlags
setting as follows:
"go.vetFlags": [
"-all",
"-vettool=~/go/bin/dogmavet"
]
Checks
The following checks are currently supported:
- Ensures
Configure()
methods call Identity()
exactly once
- Ensures
Identity()
is called with valid names and keys
- Ensures identity keys are UUIDs, formatted as per RFC-4122
Fixes
The checkers are able to provide fixes to common problems, however it seems that
go vet
does not yet expose this information for consumptions by IDEs.
The fixers can be run manually using:
dogmavet -fix ./...
Please note that all of the following fixes will be applied:
- Rename the configurer parameter name to
c
- Replace non-UUID identity keys with UUIDs
- Reformat non-standard UUID representations by the RFC-4122 grammar
Caveats
The go vet
command does not allow more than one -vettool
argument to be
provided. Furthermore, setting -vettool
disables all of the standard checks.
As a workaround, dogmavet
includes all of the standard checks along with the
Dogma-specific ones.
See also vscode-go/issues#3219.