8000 Limit generated marker detection to file headers by dajiaohuang · Pull Request #1771 · dominikh/go-tools · GitHub
[go: up one dir, main page]

Skip to content

Limit generated marker detection to file headers - #1771

Open
dajiaohuang wants to merge 2 commits into
dominikh:masterfrom
dajiaohuang:fix/generated-header
Open

dajiaohuang wants to merge 2 commits into
dominikh:masterfrom
dajiaohuang:fix/generated-header

Conversation

@dajiaohuang
@dajiaohuang dajiaohuang commented Oct 1, 2026 •
Copy link
Copy Markdown

Generated-file detection reads actual line comments before the package clause, matching Go's generated-file convention. Parse only the package clause and comments instead of scanning arbitrary source lines, while retaining recognized generator names and the legacy cgo marker.

The review follow-up removes the unsupported first-ten-lines cutoff, so generated markers following a long license header are recognized. Indented package clauses and marker-like text inside a block comment cannot trick the detector into treating a handwritten file as generated.

Validation: go test ./analysis/facts/generated passed (eight tests), including long-header, indented-package, block-comment, legacy-cgo and existing cases; gofmt and git diff --check passed.

Convention: https://go.dev/s/generatedcode; parser approach: https://pkg.go.dev/go/ast#IsGenerated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0