go-linters

Create and validate custom Go analysis linters for the gh-aw repository.

5.1k|530|Updated Aug 12, 2025
One-click install
npx skills add https://github.com/github/gh-aw --skill go-linters
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-linters
Source: https://github.com/github/gh-aw/tree/main/.github/skills/go-linters
Command: npx skills add https://github.com/github/gh-aw --skill go-linters

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Adding a new custom Go static analysis linter to the gh-aw repository requires knowing the correct package layout, analyzer registration, test conventions, and build commands, which are easy to get wrong without guidance.

Core Features & Use Cases

  • Linter Scaffolding Guidance: Directs you to create a package under pkg/linters/<linter-name>/, export an Analyzer, and register it in cmd/linters/main.go for the multichecker binary.
  • Testing Workflow: Explains how to write analysistest-based tests with fixtures under testdata/src/... and run them with go test ./pkg/linters/<linter-name>/....
  • Coverage-Aware Perf Gating: Shows how to gate performance-related diagnostics on hot code paths using the shared pkg/linters/internal/coverage package and a coverage profile.
  • Use Case: You want to add a linter that flags unnecessary allocations, but only on code paths exercised by tests. Follow the coverage-gating steps to register a -hot-threshold flag and call coverage.ShouldApply before reporting diagnostics.

Quick Start

Ask the agent to add a new custom Go linter named after your rule, register it in the multichecker, and run its package tests.

Frequently Asked Questions about go-linters

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a custom Go linter to the gh-aw repository?

Create a new package under pkg/linters/<linter-name>/, define and export an Analyzer, add analysistest tests with fixtures under testdata/src, and register the analyzer in cmd/linters/main.go so it runs via the multichecker binary.

How do I test a custom Go analysis linter?

Write tests in the linter's package using the analysistest framework with fixtures under testdata/src/..., then run go test ./pkg/linters/<linter-name>/... to execute only that linter's tests.

How do I run all custom Go linters across the repo?

Run make golint-custom, which builds the cmd/linters multichecker binary and runs it against the ./cmd/... and ./pkg/... package trees.

When should a Go linter use coverage-aware gating?

Use coverage gating only for linters with a genuine performance rationale, such as allocation or O(n²) rules, so diagnostics apply only to hot code paths exercised by tests. Readability or style linters should not be coverage-gated.

How do I generate a coverage profile for hot-path linting?

Run go test -covermode=count -coverprofile=/tmp/coverage.out ./..., export GH_AW_LINT_COVERAGE_PROFILE=/tmp/coverage.out, then run make golint-custom. Without a profile or with hot-threshold 0, gating is permissive and always reports.