-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check enum based on struct #33
Comments
This would be useful tooling generally. I'll have to think about whether I want to make it part of this program though. Primarily I want to think through the patterns/conventions that mark a given struct as an enum struct. This might be interesting: https://github.com/BurntSushi/go-sumtype. |
+1 to this. struct based enums are more robust in Go. would like to see this project to support it. |
I would rather wrap struct enums over integer type. So it is very similar to current version. |
I think it would be good to be able to specify that any type could be an enum with a Although perhaps that should be a different analyzer entirely or gated by a flag to avoid the extra cost for callers that don't want this feature. |
There is alternative approach how to deal with enums in Go.
Example: https://github.com/ThreeDotsLabs/wild-workouts-go-ddd-example/blob/master/internal/trainer/domain/hour/availability.go
Article with motivation: https://threedots.tech/post/safer-enums-in-go/.
The idea is to use struct with private field and package level variables.
It would be great if exhaustive checks such enums as well, not only constants.
The text was updated successfully, but these errors were encountered: