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 ¶
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 ¶
CheckerOptions configures a freshly constructed Checker.