Skip to content
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

entity_unmarshal: Check if type is struct before calling NumField() #113

Open
wants to merge 1 commit into
base: entities
Choose a base branch
from

Conversation

xzou
Copy link

@xzou xzou commented Mar 28, 2019

No description provided.

field := val.Type().Field(i)
tag := strings.Replace(field.Tag.Get("json"), ",omitempty", "", -1)
jsonTagToKey[tag] = field.Name
if val.Kind() == reflect.Struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this if statement should probably wrap everything i think in this function, because the part you wrapped generates jsonTagToKey and that part is used in the second part (so if we don't actually populate jsonTagToKey there's no use in doing this part.

Do you have an example for which this was breaking? Should we add something to the entity_test.go file?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes that makes sense--I've updated it! I've also added google attributes to the test. prior to my fix, adding google attributes resulted in a panic when trying to run the tests

@xzou xzou force-pushed the entities-unmarshalNonStructs branch from 40c0aef to 509e2ae Compare March 28, 2019 18:23
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.

2 participants