Our great sponsors
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
This is an analyzer that will catch this: https://github.com/nishanths/exhaustive
I believe it's in golangci-lint.
https://github.com/golang/go/issues/57644
As stated in that proposal, the interaction between what people want from “enums,” “discriminated unions,” “sum types,” (as well as “optional values” and “nil safety”) and fundamental Go tenets like zero values, make this a tough sell, which is very likely to make no one happy.
interesting approach! but I typically use this method for type constraints.
for enums I prefer just direct structs: https://github.com/nikolaydubina/go-enum-example