[FEATURE]: Adhere to Go comment convention for generated code
tessig opened this issue · 0 comments
Adhere to the Go comment convention to mark generated code with a comment that matches the strict regex: ^// Code generated .* DO NOT EDIT\.$
Context (Input, Language)
Input Format: Any
Output Language: Go
Description
Go has a comment convention for generated files: https://pkg.go.dev/cmd/go#hdr-Generate_Go_files_by_processing_source
Many code analysis tools rely on this convention. For example, the most widely used linter golangci-lint will ignore generated files that have this comment at the top.
The code generated by quicktype should follow this convention to ensure proper integration with Go tooling and workflows.
Current Behaviour / Output
Currently, quicktype generates Go code without the standard Go generated code comment. This causes linters and other tools to treat the generated code as regular code, which can lead to unnecessary linting errors and warnings.
Proposed Behaviour / Output
Modify the standard Go generated code comment at the top of all Go files generated by quicktype to match the regex:
// Code generated from JSON Schema using quicktype. DO NOT EDIT.Solution
Modify the Go renderer to add the standard generated code comment at the beginning of each generated file, before any package declarations or other content.
Alternatives
Users could manually add the comment after generation or adjust the behavior of all go tooling, but this is error-prone and needs to be repeated every time the code is regenerated.
Context
This is a common issue for Go developers using quicktype, as it affects integration with standard Go tooling. Following this convention would improve the developer experience for Go users.