Hacker News new | past | comments | ask | show | jobs | submit login

Yes, I think it's actually a decent way of doing it, given how limited golang is when it comes to enums. (Better might be to use tags, but I think they are only allowed on struct fields.)

I think codegen is generally fine for repetitive tasks. It's just a shame that golang doesn't give you a way to do this built-in. Even java has this feature, even if it's lacking in some regards.




Not sure if I understand you correctly, but Go has had a built-in way to do codegen for 10 years now: https://go.dev/blog/generate




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: