Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Defining own accessor methods on generated structs #3804

Unanswered
dolzenko asked this question in Q&A
Discussion options

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.

func (a *Author) IsClassic() bool {
 return a.Name == "Hemingway" || a.Name == "Tolstoy"
}

PS. Big thanks for all the folks opensoursing and maintaining this ❤️

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
1 participant

AltStyle によって変換されたページ (->オリジナル) /