Documentation
¶
Overview ¶
Package genheader is the single Go source of the generated-code marker apic stamps on every file it emits and of the regex the repo's guards use to detect it. Two Go consumers share it -- internal/generator's ensureGeneratedHeader (the emitter) and tools/generated_header_check.go (the guard that fails when a hand-written file falsely carries the marker) -- so they can no longer drift apart behind a comment claiming they are identical, which is how the emitter's copy came to accept only `//` while the checker's accepted `//` or `#` (QG-122, #363). The third copy, scripts/gen_headers.py's DETECT_RE / SLASH_MARKER / HASH_MARKER, cannot import a Go package; this package's test reads the script and fails if those literals stop matching the constants below.
Kept under internal/ (module root) rather than pkg/ so it is importable by both internal/generator and tools/ without being mirrored into the generated runtime trees.
Index ¶
Constants ¶
const DetectPattern = `(?m)^(?://|#) Code generated .* DO NOT EDIT\.\s*$`
DetectPattern matches the marker on a line of its own, behind `//` or `#`, anywhere in the text it is applied to (callers restrict the search to the pre-package-clause prefix where that matters). It is the Go tooling regex widened to the `#` form; the `#` alternative is inert for Go source, where no valid pre-package line starts with `#`.
const HashMarker = "# Code generated by apic; DO NOT EDIT."
HashMarker is the same marker behind `#` for hash-comment languages (YAML), so tools that scan for the phrase still pick it up.
const Marker = "// Code generated by apic; DO NOT EDIT."
Marker is the canonical Go-tooling generated-code marker (GEN-HDR). It MUST appear before the package clause of every emitted `.go` file so gopls / golangci-lint / go vet / `go generate` and the downstream Go regex `^// Code generated .* DO NOT EDIT\.$` all classify the file as generated. Slash-comment languages (Go, TypeScript, JavaScript) carry it verbatim.
Variables ¶
var DetectRE = regexp.MustCompile(DetectPattern)
DetectRE is DetectPattern compiled once for every consumer.
Functions ¶
This section is empty.
Types ¶
This section is empty.