Skip to content

Conversation

@achille-roussel
Copy link
Contributor

Fixes #28

Go does some magic when converting from non-empty to empty interfaces, the casting of *(*interface{})(p) for all interface types was not good enough.

This PR addresses it by falling back to the reflect package for this specific case. I don't anticipate this having an impact on performance, non-empty interface types in JSON are rare because they can't really be unmarshaled, and the use of reflect.NewAt and conversion of an interface to interface{} doesn't add much overhead.

I've added a test which was reproducing the bug and is now passing with the fix.

@achille-roussel
Copy link
Contributor Author

Thanks for the review!

@achille-roussel achille-roussel merged commit 7dff82d into master Jan 23, 2020
@achille-roussel achille-roussel deleted the issue28 branch January 23, 2020 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Encoding a struct with error type field fails in various ways

3 participants