Skip to content

Detect zz_generated.*.go as generated#7870

Open
pirothat wants to merge 7 commits into
github-linguist:mainfrom
pirothat:detect-go-zz-generated-files
Open

Detect zz_generated.*.go as generated#7870
pirothat wants to merge 7 commits into
github-linguist:mainfrom
pirothat:detect-go-zz-generated-files

Conversation

@pirothat
Copy link
Copy Markdown

@pirothat pirothat commented Mar 23, 2026

Description

#7784

Checklist:

  • I am adding a new extension to a language.

  • I am adding a new language.

    • The extension of the new language is used in hundreds of repositories on GitHub.com.
    • I have included a real-world usage sample for all extensions added in this PR:
      • Sample source(s):
        • [URL to each sample source, if applicable]
      • Sample license(s):
    • I have included a syntax highlighting grammar: [URL to grammar repo]
    • I have added a color
      • Hex value: #RRGGBB
      • Rationale:
    • I have updated the heuristics to distinguish my language from others using the same extension.
  • I am fixing a misclassified language

    • I have included a new sample for the misclassified language:
      • Sample source(s):
        • [URL to each sample source, if applicable]
      • Sample license(s):
    • I have included a change to the heuristics to distinguish my language from others using the same extension.
  • I am changing the source of a syntax highlighting grammar

    • Old: [URL to grammar repo]
    • New: [URL to grammar repo]
  • I am updating a grammar submodule

  • I am adding new or changing current functionality

    • I have added or updated the tests for the new or changed functionality.
  • I am changing the color associated with a language

    • I have obtained agreement from the wider language community on this color change.
      • [URL to public discussion]
      • [Optional: URL to official branding guidelines for the language]

Detect generated Go files matching *_generated.*.go
Add test for generated Go files matching *_generated.*.go
Add Go sample file for *_generated.*.go detection
@pirothat pirothat requested a review from a team as a code owner March 23, 2026 13:22
@pirothat pirothat changed the title Detect go zz generated files Detect Go zz_generated.*.go as generated Mar 23, 2026
@lildude
Copy link
Copy Markdown
Member

lildude commented May 1, 2026

Please state in the PR template where you got the sample from and it's license.

@Alhadis Alhadis changed the title Detect Go zz_generated.*.go as generated Detect Go zz_generated.*.go as generated May 1, 2026
@Alhadis Alhadis changed the title Detect Go zz_generated.*.go as generated Detect zz_generated.*.go as generated May 1, 2026
Comment thread lib/linguist/generated.rb Outdated

def generated_go?
return false unless extname == '.go'
return true if !!name.match(/(^|\/)[^\/]*_generated\..+\.go$/)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a much cleaner way to write this:

Suggested change
return true if !!name.match(/(^|\/)[^\/]*_generated\..+\.go$/)
return false unless name =~ %r{(?:^|/)[^/]*_generated\..+\.go$}

@pirothat
Copy link
Copy Markdown
Author

pirothat commented May 12, 2026

Please state in the PR template where you got the sample from and it's license.

I updated the PR template to include the sample source and license.

The sample is derived from Kubernetes' zz_generated.deepcopy.go, and the sample license is listed as Apache-2.0.

@pirothat
Copy link
Copy Markdown
Author

pirothat commented May 12, 2026

I realized almost all go file of real world project contains // Code generated lines.

I commented on issue #7784 (comment)

@pirothat pirothat closed this May 12, 2026
@pirothat pirothat reopened this May 12, 2026
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.

3 participants