Skip to content
Latchkey

go vet: Usage, Options & Common CI Errors

Catch likely bugs the compiler accepts.

go vet runs a suite of static analyzers over your code, flagging mistakes that compile fine but are almost always wrong - bad Printf format strings, useless comparisons, misused struct tags, and more.

What it does

Type-checks and analyzes packages with built-in vet analyzers. It reports findings and exits non-zero when any are found, making it a useful CI gate alongside the build. (go test also runs a subset of vet automatically.)

Common usage

Terminal
go vet ./...                      # vet every package
go vet ./auth/...                 # vet a subtree
go vet -printf=false ./...        # disable one analyzer

Common CI error: Printf argument mismatch

go vet fails with something like "fmt.Printf format %d has arg name of wrong type string." The format verb does not match the argument type. Fix: correct the verb (%s for strings, %d for ints) or the argument. These are real latent bugs - fix them rather than disabling the analyzer.

Options

FlagEffect
./...Vet all packages
-printf=falseDisable the printf analyzer
-tags <list>Set build tags for analysis

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →