Skip to content
Latchkey

go vet Command: Static Checks in CI

go vet examines Go source for likely bugs the compiler does not catch.

go vet is the built-in static analyzer for Go, run as a fast guardrail in CI alongside the build. It flags problems like mismatched Printf verbs, malformed struct tags, and copied locks that compile cleanly but are usually bugs.

Common flags

  • go vet ./... - vet every package in the module
  • -vettool=PATH - run an external analyzer (e.g. shadow, fieldalignment)
  • -tags "integration" - vet files behind specific build tags
  • -json - emit machine-readable diagnostics
  • -printf=false - disable a specific analyzer check

Example in CI

Vet the entire module as a gate before running tests:

shell
go vet ./...

Common errors in CI

  • Printf format %d has arg x of wrong type string
  • struct field tag json:name not compatible with reflect.StructTag.Get
  • call of fmt.Sprintf copies lock value: sync.Mutex
  • unreachable code

Key takeaways

  • Run go vet ./... as a cheap, fast gate before the test suite.
  • Printf-verb and struct-tag mistakes are the most common findings.
  • Plug in extra analyzers via -vettool for stricter checks.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →