System-level Go tooling hooks that delegate to existing Make targets in HyperFleet repositories.
HyperFleet Go repositories pin development tools in tools/go.mod using Go 1.24+ tool directives (see dependency pinning standard). These hooks use language: system and delegate to the consuming repo's existing Make targets, which invoke tools via go tool -modfile=tools/go.mod <name>.
Runs make lint in the consuming repository.
- Stage:
pre-commit - Entry:
make lint - Language:
system - File filtering: Triggered by Go file changes (does not pass individual filenames)
Runs make gofmt in the consuming repository.
- Stage:
pre-commit - Entry:
make gofmt - Language:
system - File filtering: Triggered by Go file changes (does not pass individual filenames)
Runs make go-vet in the consuming repository.
- Stage:
pre-commit - Entry:
make go-vet - Language:
system - File filtering: Triggered by Go file changes (does not pass individual filenames)
Add to your .pre-commit-config.yaml:
repos:
- repo: https://github.com/openshift-hyperfleet/hyperfleet-hooks
rev: main # Use latest release tag
hooks:
- id: hyperfleet-golangci-lint
- id: hyperfleet-gofmt
- id: hyperfleet-go-vetInstall the hooks:
pre-commit install --hook-type pre-commitYou don't need to enable all hooks. Pick the ones you need:
hooks:
# Just formatting and linting
- id: hyperfleet-gofmt
- id: hyperfleet-golangci-lintSince these hooks use language: system, the consuming repository must have the corresponding Make targets:
make lint- runs golangci-lint (via tools/go.mod)make gofmt— checks Go file formattingmake go-vet— runsgo vet ./...
These targets are already standard in HyperFleet repositories. Ensure tools are available:
make toolsThe consuming repository is missing the required Make target. Ensure your Makefile includes the lint, gofmt, and go-vet targets.
If make lint fails because golangci-lint is not installed, tidy the tools module:
make toolsThese hooks run the exact same Make targets, so results should be identical. If they differ, check:
- The tool module is tidy:
make verify-tools - The
.golangci.ymlconfig is present in your repo root - Pre-commit environment is not interfering (check
pre-commit run --verbose)
go vet catches issues that compile successfully but are likely bugs (e.g., unreachable code, incorrect format strings). Fix the reported issues rather than skipping the hook.