News for hackers. Stuff that matters.
Re:Safer Enums in Go by suremarc on Saturday May 14, 2022 @11:39AM (#31379032)
This is cool, but it doesn't seem like Switch is implemented for Int, and the use of runtime reflection limits the contexts in which this implementation can be used, compared to a language construct that gets compiled into efficient machine code. I wouldn't want this to be endemic in my codebase or my dependencies.
Re:Safer Enums in Go by Splizard on Saturday May 14, 2022 @11:55AM (#31379198)
Enum supports an exhaustive Switch as well, here's an example based on the blog post: https://go.dev/play/p/Ef78vLyw33g