Help us shape the future of Go! Take the 2026 Go Developer Survey

linters

package
v0.74.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 17, 2026 License: MIT Imports: 0 Imported by: 0

README

linters Package

The linters package namespace contains custom static analysis linters used by gh-aw quality checks.

Overview

This package currently provides custom Go analyzers in the following subpackages:

  • excessivefuncparams — reports function declarations that exceed a configurable parameter-count threshold.
  • largefunc — reports function bodies that exceed a configurable line-count threshold.
  • osexitinlibrary — reports os.Exit calls in library packages (pkg/*) where process termination should be delegated to cmd/* entry points.

Public API

Subpackages
Subpackage Description
excessivefuncparams Custom go/analysis analyzer that flags function declarations with too many positional parameters
largefunc Custom go/analysis analyzer that flags large functions with actionable diagnostics
osexitinlibrary Custom go/analysis analyzer that flags os.Exit usage in library packages

Usage Examples

import (
	"github.com/github/gh-aw/pkg/linters/excessivefuncparams"
	"github.com/github/gh-aw/pkg/linters/largefunc"
	"github.com/github/gh-aw/pkg/linters/osexitinlibrary"
)

// Use with multichecker, singlechecker, or custom go/analysis driver.
_ = excessivefuncparams.Analyzer
_ = largefunc.Analyzer
_ = osexitinlibrary.Analyzer

Dependencies

Internal:

  • None at the pkg/linters namespace level. pkg/linters/{excessivefuncparams,largefunc,osexitinlibrary} are documented above as subpackage APIs, not internal dependencies.

External:

  • golang.org/x/tools/go/analysis — analyzer framework
  • golang.org/x/tools/go/analysis/passes/inspect — AST inspection support
  • golang.org/x/tools/go/ast/inspector — efficient AST traversal

Design Notes

  • The package is intentionally organized as a namespace (pkg/linters/*) so individual analyzers remain isolated and independently testable.
  • excessivefuncparams exposes a -max-params analyzer flag and defaults to 8 parameters (DefaultMaxParams).
  • largefunc exposes a -max-lines analyzer flag and defaults to 60 lines (DefaultMaxLines).
  • osexitinlibrary helps enforce separation between library logic and process-level termination.

This specification is automatically maintained by the spec-extractor workflow.

Documentation

Overview

Package linters is a namespace for gh-aw's custom Go analysis linters.

The actual analyzers are implemented in subpackages — see the excessivefuncparams, largefunc, and osexitinlibrary subdirectories for analyzer entry points. This file exists so that the directory can host package-level documentation and an external test package that asserts the namespace's specification contract.

Directories

Path Synopsis
Package ctxbackground implements a Go analysis linter that flags calls to context.Background() inside functions that already receive a context.Context parameter.
Package ctxbackground implements a Go analysis linter that flags calls to context.Background() inside functions that already receive a context.Context parameter.
Package excessivefuncparams implements a Go analysis linter that flags functions with too many positional parameters.
Package excessivefuncparams implements a Go analysis linter that flags functions with too many positional parameters.
Package largefunc implements a Go analysis linter that flags functions whose body exceeds a configurable line threshold.
Package largefunc implements a Go analysis linter that flags functions whose body exceeds a configurable line threshold.
Package osexitinlibrary implements a Go analysis linter that flags os.Exit calls in library (pkg/) packages.
Package osexitinlibrary implements a Go analysis linter that flags os.Exit calls in library (pkg/) packages.
Package rawloginlib implements a Go analysis linter that flags standard log package calls in library (pkg/) packages.
Package rawloginlib implements a Go analysis linter that flags standard log package calls in library (pkg/) packages.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL