Documentation
¶
Overview ¶
Package main — anyFuncEntry is one row in the generated stdlib-any-funcs allowlist (extracted for KTN-STRUCT-ONEFILE).
Package main — anyIfaceEntry is one row in the generated any-bearing interface table (extracted for KTN-STRUCT-ONEFILE).
Package main — any-parameter extractor for KTN-INTERFACE-ANYUSE (issue #294).
Collects every exported stdlib function or method whose signature contains an `any` (or empty `interface{}`) parameter, plus every interface method signature that declares an `any` parameter. The interface set is the substrate for the types.Implements check in the rule (a user type that satisfies one of these interfaces inherits its `any` slot legitimately).
Package main — anyuseTplData template-data carrier (extracted for KTN-STRUCT-ONEFILE).
Package main — emitter dispatch record (extracted for KTN-STRUCT-ONEFILE).
Package main — funcInfo carries function/method signature metadata produced by the stdlib scanner (extracted for KTN-STRUCT-ONEFILE).
Package main — ifaceMeth describes a method declared on an interface (extracted for KTN-STRUCT-ONEFILE).
Package main is the project-native stdlib allowlist generator.
It scans $GOROOT/src for canonical Go patterns used by KTN-STRUCT-ROLE-STUTTER (issue #291), KTN-FUNC-EMPTYSENTINEL (issue #293) and KTN-INTERFACE-ANYUSE (issue #294) — emitting Go data files consumed at lint time. The output is deterministic and intended to be committed; CI runs `make generate-check` to fail if regenerating against the active Go toolchain produces a diff.
Per design (.claude/plans/issue-shared-stdlib-generator.md), this binary is invoked via `make generate` which delegates to `bazel run` so the same Go toolchain that builds the linter also generates the allowlists.
Package main — local copy of the rule's normalize() so the generator's stutter detection matches the rule's runtime comparison key exactly.
MUST stay in lockstep with internal/analyzer/ktn/structure/organization/ normalize.go. A regression test (internal/analyzer/ktn/structure/ organization/normalize_external_test.go ... or main_test.go here) covers drift between the two copies.
Package main — code rendering pipeline.
Renders the collected scanner data into Go source files using text/template + go/format.Source. Output is deterministic: keys sorted at scan time, templates iterate in insertion order, gofmt normalises layout.
Package main — scanner-side primitives shared by all kinds.
scanner walks $GOROOT/src, parses every non-test .go file, and collects:
- exported struct names (for sole-struct-per-pkg heuristic and stutter detection)
- functions, methods, and interface methods with full signature metadata
- their doc-comments (preserved via doc.New for canonical godoc form)
The walker skips internal/, testdata/, cmd/ and underscore-prefixed dirs — these are not part of the public stdlib contract.
Package main — empty-sentinel accessor extractor for KTN-FUNC-EMPTYSENTINEL (issue #293).
Targets functions/methods whose signature is `func(...) string` AND whose doc-comment explicitly documents an empty-string-as-absence contract — i.e. stdlib accessors like os.Getenv, http.Header.Get, url.Values.Get, mime.TypeByExtension, runtime.GOROOT.
The doc-anchor set is closed and case-sensitive — generator output is reviewable, and the rule mirrors the same set for its runtime check.
Package main — sentinelsTplData template-data carrier (extracted for KTN-STRUCT-ONEFILE).
Package main — stutterGroup template-data carrier (extracted for KTN-STRUCT-ONEFILE).
Package main — stutter-pair extractor for KTN-STRUCT-ROLE-STUTTER (issue #291).
For each stdlib package, collect every exported struct whose normalised name has boundary overlap (HasPrefix or HasSuffix) with the package basename's normalised form. Equality matches (PNPT — e.g. time.Time) are included because the rule's runtime path needs symmetric data.
Package main — stuttersTplData template-data carrier (extracted for KTN-STRUCT-ONEFILE).
Package main — small generic helpers used by render.go.