go vet is Go’s fast static-analysis command for finding suspicious source constructs before they become bugs or consume reviewer time. Run it across all packages with `go vet ./...`. section 5.4
Catching a formatting bug
An incorrect `fmt.Sprintf` call passes more arguments than its format string expects. Running `go vet ./...` reports the mismatch, providing specific feedback before tests run. section 5.4
go vet ./...
Use this command to check every package in the repository. section 5.4
Listing 5.6 pipeline.yml
vet:
name: Check formatting
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.18
- name: Check out code into the Go module directory
uses: actions/checkout@v2
...
- name: Vet
run: go vet ./... #1
Add a vet job after formatting checks and before tests so the pipeline filters inexpensive, actionable problems early. section 5.4
