5 ms·
I’ve found the enumer [0] library does the job of generating usable helpers without too much pain or any obvious downsides. The ability to generate JSON [un]mar
by barnabee 2y ago
I’ve found the enumer [0] library does the job of generating usable helpers without too much pain or any obvious downsides. The ability to generate JSON [un]marshallers is particularly handy.
Still, the lack of enums and enum/sum types remains by far my biggest gripe about Go.
[0] https://github.com/dmarkham/enumer https://github.com/dmarkham/enumer
- deleted 2y ago[deleted]
- PhilippGille 2y agoThe posted article mentions https://github.com/abice/go-enum https://github.com/abice/go-enum, which does the same thing, no? It even generates the consts based on a list of values in a comment.
- frou_dh 2y agoFour candidates mentioned so far in the HN comments so far. Here's 45? https://github.com/search?q=enum+generator+language%3AGo&type=repositories&l=Go https://github.com/search?q=enum+generator+language%3AGo&typ... https://github.com/search?q=enum+generation+language%3AGo&type=repositories&l=Go https://github.com/search?q=enum+generation+language%3AGo&ty...
- barnabee 2y agoIt does indeed seem to be similar, and viable option, with the difference being that the enum values are specified in a comment. You seem enthusiastic about that design decision/feature, howeever I am not sure about it, it scares me a little. It's absolutely just a hunch and personal preference but I worry that keeping the enum value inputs in comments might not be great for new contributors and in terms of maintaining the codebase over time, so I think I prefer the approach taken by enumer.