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:namenot 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
-vettoolfor stricter checks.
Related guides
go build Command: Compile Go in CIgo build compiles Go packages. Reference for -o, -ldflags, -tags, -race, GOOS/GOARCH cross-compilation, and t…
cargo Command: Build & Test Rust in CIcargo is the Rust build tool and package manager. Reference for build, test, --release, --locked, --all-featu…
tsc Command: Compile TypeScript in CItsc is the TypeScript compiler. Reference for --noEmit, --project, --watch, --build, --outDir, --strict, and…