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

Generator flag to default to tuples instead of maps #186

Open
shabbyrobe opened this issue Jul 21, 2017 · 3 comments
Open

Generator flag to default to tuples instead of maps #186

shabbyrobe opened this issue Jul 21, 2017 · 3 comments

Comments

@shabbyrobe
Copy link
Contributor

We are using tuples for everything in our application for performance and compactness. I'd love to be able to replace the 200 or so //msgp:tuple directives with a single flag to the generator //go:generate msgp -tuple.

I suppose this means there'd need to be a new directive //msgp:map, orthogonal to //msgp:tuple in the default mode.

Happy to have a stab at this if you think it'd be worth including. It'd certainly make my life a lot easier!

@glycerine
Copy link
Contributor

greenpack[1], which descends from Phil's terrific work here in msgp, has an -alltuple flag that does what you'd like. See the example [2].

[1] https://github.com/glycerine/greenpack

[2] https://github.com/glycerine/greenpack/blob/master/testdata/my4.go and https://github.com/glycerine/greenpack/blob/master/testdata/tupledefault_test.go

@shabbyrobe
Copy link
Contributor Author

shabbyrobe commented Aug 7, 2017

Greenpack goes a lot further than I need though. I can't trivially switch from msgp to something so different at this point in my project's life. How hard would it be to integrate those features from greenpack back into msgp?

@glycerine
Copy link
Contributor

glycerine commented Aug 7, 2017

greenpack -omit-clue gives you straight msgpack, no change in field names. But if you are doing greenpack -alltuple then there are no fieldnames to begin with, so I'm not sure what you think is different. Feel free to open an issue there with any questions, I don't want to get too off topic here.

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

No branches or pull requests

2 participants