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

Ability to match field names in a case sensitive manner #207

Closed
wants to merge 4 commits into from

Conversation

mflorin
Copy link

@mflorin mflorin commented Oct 20, 2020

Fixes #208
I've added a new configuration option and the associated code to be able to match map keys to field names case sensitively.
However, the first letter of struct field names is still compared case insensitively, to allow for the Go convention of publicly exported member names.

@mitchellh
Copy link
Owner

Thanks! I think the "ignore first character" is a bit odd... though I understand why you did it. Can you add a test for this?

@rpajak-solarwinds
Copy link

rpajak-solarwinds commented Nov 30, 2020

Thanks! I think the "ignore first character" is a bit odd... though I understand why you did it. Can you add a test for this?

I agree with @mitchellh .

|| strings.Title(mK) == fieldName should be removed. There should be another config to enable such matching.

@mitchellh any chances to have it soon? I want to use CaseSensitive together with ErrorUnused to have a very strict control during decoding.

@mflorin
Copy link
Author

mflorin commented Dec 10, 2020

Yes, agreed, the logic is odd :) I think @rpajak-solarwinds 's idea to have a config would work. I'll make the necessary changes.

@mflorin
Copy link
Author

mflorin commented Dec 10, 2020

@mitchellh , @rpajak-solarwinds I've added another config, TitleCaseInsensitive which works together with CaseSensitive. I've also added the tests. Let me know if that works better :) . Thanks.

@mitchellh
Copy link
Owner

I went with #250 since that supports any custom name matching logic. Sorry, but thank you!

@mitchellh mitchellh closed this Sep 14, 2021
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.

Ability to match map keys case sensitively
3 participants