Skip to content

all: match go conventions for generated code #6731

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 5, 2025

Conversation

seankhliao
Copy link
Contributor

Go documents the following regex pattern
for identifying generated code:
^// Code generated .* DO NOT EDIT.$

This convention is used go APIs and tooling.
References:
https://pkg.go.dev/go/ast#IsGenerated
https://pkg.go.dev/cmd/go#hdr-Generate_Go_files_by_processing_source

Go documents the following regex pattern
for identifying generated code:
^// Code generated .* DO NOT EDIT\.$

This convention is used go APIs and tooling.
References:
https://pkg.go.dev/go/ast#IsGenerated
https://pkg.go.dev/cmd/go#hdr-Generate_Go_files_by_processing_source
@MrAlias MrAlias added the Skip Changelog PRs that do not require a CHANGELOG.md entry label May 4, 2025
@dmathieu dmathieu merged commit 1d88248 into open-telemetry:main May 5, 2025
29 checks passed
@pellared
Copy link
Member

pellared commented May 5, 2025

This comment was crafted this way intentionally so that the linters analyze the code as the code is manually written in go.tmpl files.

@seankhliao
Copy link
Contributor Author

I think in that case it's better to configure the linters to not ignore the file, rather than having something that looks like a mistake?

e.g. golangci:

issues:
  exclusions:
    generated: disable

@pellared pellared added this to the v1.36.0 milestone May 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Skip Changelog PRs that do not require a CHANGELOG.md entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants