-
Notifications
You must be signed in to change notification settings - Fork 14
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
error type out of range when use for embed fields #1
Comments
Thank you for the report! The issue should be fixed by 5656e2f commit, please check. |
Thank you @sevlyar for example in my sample code I need a struct with type Product but it return *struct and I can't cast it! |
@Mehrdad-Dadkhah, You can use next code if you need a structure instead of pointer: gormProductPtr := Convert(product, NewView("json", "gorm"))
gormProduct := reflect.ValueOf(gormProductPtr).Elem().Interface() But i don't understand a source of your requirements. Could you clarify your case of retag using? It would help me to extend scope of using. |
Thanks for reply @sevlyar I test it but I have error!
And error:
|
About my case, I have a adaptor for gorm orm and another one for other. Gorm need a struct that gorm.Model was embedded to it and another (for example X) orm don't need it. |
@Mehrdad-Dadkhah Convert requires pointer (&product): gormProductPtr := retag.Convert(&product, retag.NewView("json", "gorm")) I will add semantic error message for that case. |
@sevlyar
and output is:
one question: thanks very very much for help me @sevlyar |
@Mehrdad-Dadkhah product := Product{}
ptr := &product
newPtr := retag.Convert(ptr, retag.NewView("json", "gorm"))
// Now ptr and newPtr both point on the same memory - product.
// ...
connection.First(&newPtr, 1)
// Now fields of the product are completely filled by gorm:
fmt.Println(product.Code, product.Price) p.s. |
hi
tnx for good package.
when I run this code:
output error is:
go version:
go version go1.8 linux/amd64
The text was updated successfully, but these errors were encountered: