go-vet
Static analysis for Go source code
TLDR
Check current package
$ go vet
Check specific package$ go vet [package]
Check all packages$ go vet ./...
Run specific analyzer$ go vet -[analyzer] [package]
List analyzers$ go vet -help
SYNOPSIS
go vet [options] [packages]
DESCRIPTION
go vet examines Go source code and reports suspicious constructs that the compiler does not catch. It finds bugs like incorrect printf format strings, unreachable code, and misuse of sync primitives.The tool runs multiple analyzers that check for common mistakes. It is part of the standard quality assurance workflow alongside testing and formatting.
PARAMETERS
PACKAGES
Packages to check.-json
JSON output.-c N
Display offending line with N lines of context.-v
Verbose output.-n
Print commands but do not run them.-x
Print the commands as they are executed.-vettool prog
Select a different analysis tool.-tags TAGS
Build tags.
CAVEATS
Not exhaustive; false positives are possible. Use alongside tests and code review. Run `go help vet` for full documentation. Additional analyzers (like shadow) require `-vettool`.
HISTORY
go vet is part of the Go toolchain, providing static analysis for catching common programming errors.
SEE ALSO
go(1), staticcheck(1), golint(1)
