It seems like none of the other comments here use or are even aware of `go generate`. Go has excellent code generation features [1].
I think parent should be using `stringer` [2] instead.
Re:Go Is a Well-Designed Language
by physicsguy on Friday January 31, 2025 @03:44AM
(#42885799)
I'm well aware of Stringer but I don't again think it's a good replacement of having enums built in!
> I don't again think it's a good replacement of having enums built in!
I didn't say anything along those lines, in fact I was commenting generally about this issue that you guys and the other commenters mentioned.
I was just suggesting a solution to the the problem stated.
Re:Go Is a Well-Designed Language
by fullstackchris on Friday January 31, 2025 @01:34PM
(#42890278)
"We don't want a solution! We want to complain about what we are used to and dont have!"
In your suggested method it doesn’t even catch that case and provide an error if the value isn’t in the range.