-
Notifications
You must be signed in to change notification settings - Fork 294
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
fix #1772: EncodeType doesn't unify embedded Go struct with struct definition #1775
base: master
Are you sure you want to change the base?
Conversation
Thanks @yangzhares - I'll defer to @mpvl for a review here. In the meantime, please can you take a look at the contribution guide on commit messages? https://github.com/cue-lang/cue/blob/master/doc/contribute.md#good-commit-messages That gives advice on the scheme we follow there. Thanks |
I'm curious what happens if the embedded struct does not have a json tag. A test covering this would be nice too, if it doesn't already exist somewhere |
…nition This actually fixes a bug in GoTypeToExpr under internal/core/convert, it doesn't unify embedded Go struct with struct definition, and add two test cases to verify this fix working well. Fixes: cue-lang#1772 Signed-off-by: Clare Yang (zhanyang) <[email protected]>
@yangzhares That looks to cover what I was thinking about, though now I'm wondering what happens with E. type EmbeddedObj struct {
B int `json:"b"`
D string
E string `json:"e",omitempty`
} |
Based on current logic 1) goTypeToValueRec, https://github.com/cue-lang/cue/blob/master/internal/core/convert/go.go#L693, 2) getName, https://github.com/cue-lang/cue/blob/master/internal/core/convert/go.go#L99, 3)isOptional, https://github.com/cue-lang/cue/blob/master/internal/core/convert/go.go#L139, to handle such case, especial field {
b: ((int & >=-9223372036854775808) & <=9223372036854775807)
D: string
e: string
} |
I'm not familiar with the code, mostly just thinking about test cases to cover all the scenarios, especially when code changes in the future |
@yangzhares apologies that we hadn't gotten back to this yet. It appears that other fixes have caused conflicts here. Would you be able to fix those and rebase? I'm happy to review afterwards. Thank you! |
Signed-off-by: Clare Yang (zhanyang) [email protected]