-
Notifications
You must be signed in to change notification settings - Fork 63
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 request: Optionally generate non-nested structs #14
Comments
Semi-manual workaround:
|
Thanks for reporting this issue (and for documenting a workaround). This is a trade-off, currently - where the emphasis is on reading XML (as opposed to generating it) - and also readability: the complete structure is mirrored in a single struct. It would be nice to have an option to generate separate structs; although I cannot work on it ATM (zek is a prototype and works ok for the use case it covers). I'll leave this issue open, just in case I find time to address this issue. |
I would really like this feature too. Mainly because much of the hierarchy contains stuff I don't need, and I have functions that return a type that is deeply nested (for now I've manually pulled out the sections I need and turned them into named types). |
@NickLarsenNZ, thanks for the feedback. Cut and paste is the way to go at the moment, I'm afraid. But as time permits, I'll look into it. |
Hi @miku , thanks for the package! Would definitely find it great as well to extract nested structs to their own types. Thanks! |
@periode, noted. I'll put this next on my list of improvements for zek. |
Also happy to offer a PR if you point me in the right direction! |
In JSON-to-Go it is called "Inline type definitions"; |
Right now zek generates nested structs, with one struct being nested in another.
The downside of this is that it is (apparently) not possible to attach methods to the nested struct.
Hence the question, can zek be extended to optionally generate non-nested structs?
Real-life code example:
https://github.com/probonopd/go-scribus/blob/48984ecccda9be0d30a4e7cb5be50670520f7dd2/scribus.go#L740-L748
The text was updated successfully, but these errors were encountered: