lintrawgo

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2026 License: Apache-2.0 Imports: 9 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package lintrawgo provides a go/analysis Analyzer that fails the build when production code launches a goroutine via a raw `go` statement instead of run.Go, run.GoOrDie, or run.GoWithSignal.

The wrappers in pkg/run install panic recovery and breadcrumb propagation around each goroutine; raw `go` bypasses both, so a panic in the worker silently kills the process. The analyzer exists to make that mistake unrepresentable in code that ships.

The check is wired into `make lint` and runs before every push and in CI. New violations fail the build. Existing sites are tracked in a checked-in baseline so the policy can be rolled out incrementally; a site cleared from the baseline cannot reappear without surfacing.

Three escape hatches exist for legitimate raw `go` usage:

  • Path allowlist: pkg/panicdiag/... and pkg/run/goroutine.go are skipped because they implement the wrappers.
  • Inline directive: a comment of the form //panicdiag:allow-rawgo <reason> on the line above the `go` statement suppresses the diagnostic for that one site. The reason text after the directive is mandatory and is what reviewers will read; "TODO" or empty justifications fail.
  • Baseline file: a list of file:line pairs grandfathered in at rollout. The format is documented at the top of the baseline file.

Index

Constants

This section is empty.

Variables

View Source
var Analyzer = newAnalyzer()

Analyzer is the go/analysis hook. The flag set is exposed via Flags so callers (singlechecker, multichecker, golangci-lint) can surface them.

Functions

This section is empty.

Types

type Checker

type Checker struct {
	// contains filtered or unexported fields
}

Checker drives the analyzer outside the analysis.Pass machinery. The standalone driver uses it so packages that fail type-checking still receive raw-go diagnostics: it loads files in syntax-only mode and passes their AST through Checker.Check.

func NewChecker

func NewChecker(opts CheckerOptions) *Checker

NewChecker returns a Checker with options resolved at construction time. The baseline file (if any) is loaded lazily on first Check.

func (*Checker) Check

func (c *Checker) Check(fset *token.FileSet, importPath string, f *ast.File) ([]analysis.Diagnostic, error)

Check returns diagnostics for one parsed file. importPath is the canonical import path of the package the file belongs to and is used for allowlist matching; pass an empty string for files outside the module (they will be checked normally).

type CheckerOptions

type CheckerOptions struct {
	BaselinePath string
	IncludeTests bool
}

CheckerOptions configures a freshly constructed Checker.

Jump to

Keyboard shortcuts

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