Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: retain struct tags from definition #8

Closed
wants to merge 1 commit into from

Conversation

mgutz
Copy link

@mgutz mgutz commented Jun 30, 2020

This utility is wonderful! I wasted so much time trying to get Twirp, gRPC working end to end with database marshalling. This utility keeps it simple.

I found myself having to add struct tags to generated structs for use with database packages. Code regen would break things. This PR retains struct tags from the original definition and allows adding/overriding of tags in templates with structTag helpers.

// render existing tags with backticks or EMPTY
<%= struct_tag(field.Tag) %>

// render tags overriding or setting fruit key
<%= struct_tag2(field.Tag, "fruit:\"apple\"") %>

@mgutz mgutz changed the title feature: retain struct tags from structs feature: retain struct tags from definition Jun 30, 2020
@matryer
Copy link
Contributor

matryer commented Jul 21, 2020

@mgutz Thanks for your contribution. We're working on this a little, we weren't keen on struct_tag2 as a method name, so we're going to go with format_tags inside the template. It takes a variadic function, and works just like your struct_tag and struct_tag2 methods. Pushing shortly.

matryer added a commit that referenced this pull request Jul 21, 2020
@matryer
Copy link
Contributor

matryer commented Jul 21, 2020

Thanks for the inspiration @mgutz - release is https://github.com/pacedotdev/oto/releases/tag/v0.6.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants