Skip to content

Latest commit

 

History

History
119 lines (79 loc) · 3.32 KB

File metadata and controls

119 lines (79 loc) · 3.32 KB

Go Tooling Hooks Documentation

System-level Go tooling hooks that delegate to existing Make targets in HyperFleet repositories.

Table of Contents

Overview

HyperFleet Go repositories use bingo to pin development tool versions (see dependency pinning standard). Rather than reimplementing bingo resolution, these hooks use language: system and delegate to the consuming repo's existing Make targets, which already handle tool resolution via bingo.

Hooks

hyperfleet-golangci-lint

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)

hyperfleet-gofmt

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)

hyperfleet-go-vet

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)

Configuration

Basic Setup

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-vet

Install the hooks:

pre-commit install --hook-type pre-commit

Selective Hooks

You don't need to enable all hooks. Pick the ones you need:

hooks:
  # Just formatting and linting
  - id: hyperfleet-gofmt
  - id: hyperfleet-golangci-lint

Prerequisites

Since these hooks use language: system, the consuming repository must have the corresponding Make targets:

  • make lint — runs golangci-lint (typically via bingo)
  • make gofmt — checks Go file formatting
  • make go-vet — runs go vet ./...

These targets are already standard in HyperFleet repositories. Ensure bingo-managed tools are built:

make tools-install

Troubleshooting

make: *** No rule to make target 'lint'

The consuming repository is missing the required Make target. Ensure your Makefile includes the lint, gofmt, and go-vet targets.

golangci-lint binary not found

If make lint fails because golangci-lint is not installed, build the bingo-managed tools:

make tools-install
# or
bingo get

Different results from direct make lint

These hooks run the exact same Make targets, so results should be identical. If they differ, check:

  1. The bingo binary exists: ls .bingo/golangci-lint-*
  2. The .golangci.yml config is present in your repo root
  3. Pre-commit environment is not interfering (check pre-commit run --verbose)

go vet fails but code compiles

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.