Repository navigation
Replies: 1 comment
|
Yes—add a normal, handwritten Go file in the same directory/package as the generated model. No sqlc plugin or template customization is required. The linked PostgreSQL tutorial configures package tutorial
func (a *Author) IsClassic() bool {
return a.Name == "Hemingway" || a.Name == "Tolstoy"
}Keep the generated The relevant restriction is Go's method receiver rule: the receiver's base type must be defined in the same package as the method. Putting this in your importing application's |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
So I wanted to add my own methods to generated structs, is it possible out of the box? Sorry wasn't able to figure out from the docs. Using https://docs.sqlc.dev/en/stable/tutorials/getting-started-postgresql.html as an example I want to add e.g.
PS. Big thanks for all the folks opensoursing and maintaining this ❤️
All reactions