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

Fixing a bug where conform panics if a field isn't a struct #15

Merged
merged 1 commit into from
May 16, 2018

Conversation

gislik
Copy link
Contributor

@gislik gislik commented May 16, 2018

Conform was choking on a field in a struct which has a type of []byte.

The problem was in the recursive Strings method in which reflection is used to figure out the number of fields in a struct. In this edge case the []byte was passed in a recursive walk of the struct which resulted in a panic when calling ift.NumFields().

This is documented here:

NumField returns the number of fields in the struct v. It panics if v's Kind is not Struct.

My solution is to return early in case the reflected variable is not a struct.

Thank you for your work!

@leebenson leebenson merged commit 5cb2fde into leebenson:master May 16, 2018
@leebenson
Copy link
Owner

Awesome, thanks @gislik !

@gislik
Copy link
Contributor Author

gislik commented May 16, 2018

👍

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.

None yet

2 participants