-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
docs: document standard way to recognize machine generated files #25433
Comments
Additionally, I think the go tool documentation is a good place to mention this.
|
He said:
Meaning that the wiki might not be an appropriate place to put it, since it can be edited by anyone. The current canonical documentation is the comment by Rob Pike in that issue, with the https://golang.org/s/generatedcode link pointing to it. |
Ah, I interpreted it as the wiki would be edited to link to Rob's comment without any need for a discussion. |
Change https://golang.org/cl/118756 mentions this issue: |
This change updates the go tool's documentation under the section "Generate Go files by processing source" to mention the convention that generated source files should have a line of text that matches the following regular expression: ^// Code generated .* DO NOT EDIT\.$ Previously, the canonical documentation for this convention (https://golang.org/s/generatedcode) referenced Rob Pike's comment at https://golang.org/issue/13560#issuecomment-288457920. This change merely moves that information to a more visible place. Updates #25433. Change-Id: I804d95d307d1dc68cb28da3750ebe9090178c474 Reviewed-on: https://go-review.googlesource.com/118756 Reviewed-by: Rob Pike <[email protected]>
Closed by https://golang.org/cl/118756 |
Change https://golang.org/cl/158817 mentions this issue: |
This CL attempts to restore the clarity of the original specification at https://golang.org/s/generatedcode that the line may appear anywhere. It is preferable (for human readability), and most common for it to be early in the file, but that is merely a convention, not a strict well-specified requirement. Document it as so. Background Issue #13560 was a proposal define a standard for marking files as generated, one that is suitable to be recognized both by humans and machine tools. It was accepted, and the final specification was documented at https://golang.org/s/generatedcode. Its text, copied exactly: Generated files are marked by a line of text that matches the regular expression, in Go syntax: ^// Code generated .* DO NOT EDIT\.$ The .* means the tool can put whatever folderol it wants in there, but the comment must be a single line and must start with Code generated and end with DO NOT EDIT., with a period. The text may appear anywhere in the file. The https://golang.org/s/generatedcode link points to a comment in a very large GitHub issue. That makes it harder to find. Issue #25433 was opened about moving that information somewhere else. It was resolved via CL 118756, which added text to cmd/go documentation at https://golang.org/cmd/go/#hdr-Generate_Go_files_by_processing_source: To convey to humans and machine tools that code is generated, generated source should have a line early in the file that matches the following regular expression (in Go syntax): ^// Code generated .* DO NOT EDIT\.$ The CL description noted that "This change merely moves that information to a more visible place." The intention was to preserve the specification unmodified. The original specification was very clear that "The text may appear anywhere in the file." The new text in cmd/go documentation wasn't very clear. "A line early in the file" is not a precise enough criteria to be recognized by a machine tool, because there isn't a precise definition of what lines are "early in the file". Updates #13560 Updates #25433 Updates #28089 Change-Id: I4e374163b16c3f972f9591ec2647fd3d5a2dd5ae Reviewed-on: https://go-review.googlesource.com/c/158817 Reviewed-by: Rob Pike <[email protected]>
in #13560 (comment) bradfitz said the wiki would be edited but I can't seem to find anything on the wiki or even googling
golang standard comment on machine generated files
. Only the original issue comes up. We should document it somewhere appropriate.Maybe https://blog.golang.org/generate could be updated to mention it?
The text was updated successfully, but these errors were encountered: