Documentation
¶
Overview ¶
Package gomarker recognises Go's generated-code marker.
It exists because two things in this module need the same answer and must not answer it differently. The coverage gate excludes generated files from its denominator; the scan excludes them from the scanned-code boundary. Both are "is this file machine-written", and a file that counted as generated for one and hand-written for the other would make the two reports disagree about the same tree for a reason nobody could see from either of them.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsGenerated ¶
IsGenerated reports whether src carries the generated-code marker in the region where it counts: before the first non-comment, non-blank line.
The position requirement is the whole point. A file can perfectly well contain the string `// Code generated ... DO NOT EDIT.` inside a function, in a test fixture for this very tool, or in a doc comment describing the convention, and none of those make the file generated. Reading only the preamble means a hand-written file cannot exempt itself from the coverage floor, or from the scan, by mentioning the marker in passing.
It reads bytes rather than an AST so the answer is available before a parse, which is what lets the scanner drop a generated file without paying to parse it. Bytes are also all the coverage gate has: it works from a profile and never builds a syntax tree at all.
Types ¶
This section is empty.