-
Notifications
You must be signed in to change notification settings - Fork 224
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 is returned when passing a pointer to an interface variable to decode #32
Comments
The test checks for When you use schema, you should be aware that returning http://play.golang.org/p/vxXM9c2m68 is a simple demonstration of mutability and immutability in structs passed by interface and accessed through reflection. |
@spirozh I think you are a bit off the track (unless I'm wrong). The issue is that Schema doesn't decode into &interface{} . Reflect can see through interface{} and also set it if it's a pointer there. See below an example with both json which works and schema which fails with the error mentioned by OP.
|
Here is a simpler version of the problem:
UpdateMy mistake. I just read the source and realized that my problem was that I should be passing the value, not the pointer:
Note for search engine users: The original error I was having personally, was do to how I was passing the struct: |
This issue has been automatically marked as stale because it hasn't seen a recent update. It'll be automatically closed in a few days. |
still happens |
@hanrok please provide more information if the existing answers do not solve your problem. Please provide code showing the issue. |
When calling decode, if you pass a pointer to an interface variable, you get an error:
schema: interface must be a pointer to struct
Here is code to reproduce:
To avoid some boilerplate code, I need to be able to have some reusable code that can pass an interface variable pointer to decode.
The text was updated successfully, but these errors were encountered: