You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Proposal: Add option to emit //go:generate annotation #3124
I would like sqlc to provide an option to emitting //go:generate annotation on generated models file in order to let us auto-generate the extended codes using go generate command.
Proposal
I would like to add some option like go_generate_annotations in config that lead sqlc to emit go:generate annotation.
I was firstly looking for the way to add getter/setter methods to the sqlc-generated models, and found that there is no straightforward option to achieve, nor any plan in future to support it. Instead, there have been some comments to the following issues that encouraging the use of any another tool to extend the code.
Golang already provides an official go generate subcommand (https://go.dev/blog/generate) that let us autogenerate the code, but that command requires //go:generate annotation on the subjected file in order to tell the command which file should be subjected and which plugin should be used for autogeneration.
Goal
I confirmed that I was able to add extra struct tags to the columns of the model struct can be achieved with following config:
Activity
kyleconroy commentedon Jan 11, 2024
Would you get the same behavior if you created an empty Go file in the same directory that had the go generate directive and nothing else?
If so, that feels like a more configurable option.
ktogo commentedon Jan 11, 2024
Ah I see. That will surely work! Thanks!