-
-
Stream
Stream - Scalable APIs for Chat, Feeds, Moderation, & Video. Stream helps developers build engaging apps that scale to millions with performant and flexible Chat, Feeds, Moderation, and Video APIs and SDKs powered by a global edge network and enterprise-grade infrastructure.
-
I’ve found the enumer [0] library does the job of generating usable helpers without too much pain or any obvious downsides.
Still, the lack of enums and enum/sum types remains by far my biggest gripe about Go.
[0] https://github.com/dmarkham/enumer
-
+1. Here is another alternative. I find this generator more lightweight and better syntax:
https://github.com/nikolaydubina/go-enum-encoding
-
There are two linters that add those checks: https://github.com/nishanths/exhaustive for values and https://github.com/alecthomas/go-check-sumtype for types. Both are integrated into golangci-lint. I use both a lot and have only a positive experience.
Having support from the language would be nice, though.
-
There are two linters that add those checks: https://github.com/nishanths/exhaustive for values and https://github.com/alecthomas/go-check-sumtype for types. Both are integrated into golangci-lint. I use both a lot and have only a positive experience.
Having support from the language would be nice, though.
-
There's also https://github.com/abice/go-enum, which I decided to use after evaluating multiple such tools a while ago, but I don't remember exactly why it came out on top for me. Also, both (and others) have evolved since then, so things might have changed.
One nice thing go-enum does is to even generate the consts, just from a list of values in a comment.