-
Notifications
You must be signed in to change notification settings - Fork 154
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
add enum support for modelgen #147
Conversation
dce1989
to
2d1cbdf
Compare
Pull Request Test Coverage Report for Build 924693681
💛 - Coveralls |
2d1cbdf
to
3f6da72
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @halfcrazy this looks good! It needs a rebase since #143 has moved this template to a package.
b404ad7
to
22eafef
Compare
rebased |
22eafef
to
7286faf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @halfcrazy for this PR, it's pretty neat.
Apart from a few comments, I'd like to ask you if you have tested the generated structs against the API. Changing the type might confuse the bindings layer...
Yes, I have tested play with ovs example. |
39faacb
to
2a3fc6f
Compare
I think that is not enough.
|
Yeah this is going to be nasty. Running
We're going to need to use |
Because diving in deep on reflection isn't the easiest thing for new contributors, I've opened #151 which, when applied, makes the |
You are awesome |
change
$ go run ./example/play_with_ovs -ovsdb unix:`pwd`/db.sock
Silly game of stopping this app when a Bridge with name "stop" is monitored !
Enter a Bridge Name : bridge
Bridge Addition Successful : 524f8b36-6d1e-42d5-8ca3-cb6b600cf4c8
Enter a Bridge Name : Current list of bridges:
UUID: 524f8b36-6d1e-42d5-8ca3-cb6b600cf4c8 Name: bridge |
c3e3dea
to
c51c525
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@halfcrazy good find! I read that yesterday but the difference between type T1 string
and type T1 = string
didn't log in my brain 😆
As you pointed out, as the type alias is invisible at runtime we can use this without adding any more reflection 🎉 . There is however a trade-off:
https://play.golang.org/p/FUWw6m9Wbiq
In that example, I can assign my type C = string
to a field that is supposed to be type A = string
. At least with the type alias we give the user a "hint" as to the values they are supposed to use, but the compiler isn't going to help you out.
However, having Enums implemented outweighs this, because we can always change the way enums are generated in future to be more strongly typed.
So, this LGTM.
@halfcrazy could you please squash your commits?
I'll let @amorenoz review this one (again) before we merge
c51c525
to
28ddaa6
Compare
Done. This is a trade-off we lose the compile-time check, but we don't need to touch reflect code, it's acceptable. We may refactor later. |
The tradeoff seems reasonable to me. Thanks @halfcrazy for the work. |
Fix #133