go vet
The go subcommand that looks for code that compiles but is probably wrong, such as a print format verb that does not match its argument.
In more detail
The compiler only rejects code that breaks the language rules; vet catches suspicious patterns the compiler allows. A classic example is printing a string with %d, which compiles but prints garbage. Run it in the pipeline next to the tests.
Example
go vet ./...Related terms
- go test — The go subcommand that builds a test binary from the _test.go files in a package, runs every test function and reports what failed.
- format verb — A placeholder starting with % in a format string, such as %s or %d, that says how to print the matching argument.
- linter — A tool that reads code or configuration without running it and flags likely mistakes and style problems.
- gofmt — The standard Go formatter, which rewrites source code into the one agreed layout so nobody argues about style.
Taught in
- Installing the Go Toolchain — Concurrent Systems Programming with Go