-
Notifications
You must be signed in to change notification settings - Fork 23
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
Other solution for generated enums #57
Comments
I'm working on a more full featured example generated code now.. |
I have uploaded some beginnings at the thrift4go organisation. The most interesting file: |
Looks good, let's change unexpected to be something extremely unlikely:
|
Make
|
|
Actually, Thrift defines all enums to be an i32 value. So math.MinInt64 is fine. |
Hmm... that would work yes.. |
New thread as reply on #56
An other solution to this would be to create a package for each EnumType. However, I don't really like that solution as it will create a lot of packages and package references.
An third solution might be to define and instantiate a struct containing al EnumNames as fields.
Thrift code:
Generated Go code:
Usage example:
You could also add methods on the StatusEnum:
Using the FromInt64 method might lead to the statusEnumType becoming unexported. Making it imposible to create a invalid StatusEnum value.
I think that this solution might be cleaner and safer, but will probably cost a lot more performance.
The text was updated successfully, but these errors were encountered: