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

Set keys case sensitive #1

Merged
merged 2 commits into from
Aug 30, 2019
Merged

Set keys case sensitive #1

merged 2 commits into from
Aug 30, 2019

Conversation

gbunt
Copy link
Owner

@gbunt gbunt commented Aug 30, 2019

kudos to @knadh

Add viper.SetKeysCaseSensitive() to disable automatic key lowercasing.

YAML, TOML, and JSON dictate keys to be case-sensitive. Viper's default
behaviour of lowercasing the keys for key insensitivity is incompatible
with these standards and has the side effect of making it difficult for
use cases such as case sensitive API credentials in configuration.
For eg: MyApiKey=MySecret (in TOML).

See spf13#131, spf13#260, spf13#293, spf13#371, spf13#373

This commit adds a global function viper.SetKeysCaseSensitive() that
enables this behaviour to be turned off, after which, all keys, irrespective
of nesting, retain their cases. This respects all configuration operations
including getting, setting, and merging.

@gbunt gbunt merged commit e3fecf5 into master Aug 30, 2019
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