Use any in generated code, apply go fix - #23
Conversation
|
the
remote, and the template already has this exposure through the |
0243b85 to
524ab38
Compare
go fix rewrites a HasPrefix and TrimPrefix pair into strings.CutPrefix, and the
interface{} parameter of a test helper into any. The generated Scan keeps
interface{}: the enum type has to be lowercase, so a package generating for
type any shadows the alias and the generated assertions stop compiling.
The committed generated files are regenerated. That brings the examples up to
date with the case-insensitive parsing added to the template earlier, and
leaves the integration test data byte for byte what the generator produces, so
running the tests no longer leaves a modified file behind.
One test asserted that the generated code contains "value int", which only
ever matched the interface{} in Scan. The enum in that test is uint8 based, so
the assertion now names the field type it has.
524ab38 to
9c1d059
Compare
The workflow already granted contents: read at the top level, the job did not say anything of its own. Code scanning reports a job that does not limit the token, so the job states the same permission explicitly.
|
Reverted, Kept the Rebased on master. The committed generated files are regenerated, which brings the examples up to date with the case-insensitive parsing added to the template earlier and leaves the integration test data byte for byte what the generator writes, so a test run no longer leaves a modified file in the tree. I also checked for dependency updates and there are none to take: both modules are on the newest versions that keep the Separately, the last commit gives the build job its own |
Previously the generated
Scanmethod took aninterface{}parameter while the rest of the template already usedany. After this change the template emitsanythroughout.go fixmakes the same replacement in a test helper and rewrites aHasPrefix/TrimPrefixpair intostrings.CutPrefix.The committed generated files are regenerated. That also brings the examples up to date with the case-insensitive parsing added to the template earlier, and leaves the integration test data byte for byte what the generator produces, so running the tests no longer leaves a modified file behind.
One test asserted that the generated code contains
value int, which only ever matched because of theinterface{}inScan. The enum in that test isuint8based, so the assertion now names the field type it actually has.What changes for existing users: generated code no longer compiles in a module that declares a language version below Go 1.18, and a consumer package that declares its own
anyidentifier shadows the predeclared one the generated type assertions rely on. The template already emittedanyin the YAML block, so the second case was reachable before this change.