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

Case insensitive ini keys #36

Closed
gpaterno opened this issue Mar 17, 2016 · 5 comments
Closed

Case insensitive ini keys #36

gpaterno opened this issue Mar 17, 2016 · 5 comments

Comments

@gpaterno
Copy link

Please support case insensitive keys and sections in an ini file, ex: via an option.
ex: treat "FOO = bar" like "foo = bar" or "Foo = bar".
Thanks

@unknwon
Copy link
Member

unknwon commented Mar 17, 2016

Hi, can you give an example use of this feature?

@gpaterno
Copy link
Author

Sure. Sometimes keys are written by users in mixed case format, even if you specify in the docs that have to be lowercase. So that, you can have in ini file:

FOO = bar
Foo = bar
foo = bar

Would be able to retrieve the same value using case insensitive key retrieval.
Hope that I was able to express myself :(
Thanks.

@unknwon
Copy link
Member

unknwon commented Mar 22, 2016

Thanks, so there is one problem left, inside the library, all key names will be stored as in lower cases. Therefore if you want to write out them, output format will have all lowercase key names.

Does this sound OK to you?

@gpaterno
Copy link
Author

Apologies for the long-waiting answer.
Yes! The most problematic is the read .... as much as you can specify and tell hard the user to watch out how they write by hand the .ini file, they will use mixed cases. :(
Thanks.

unknwon added a commit that referenced this issue Jun 29, 2016
unknwon added a commit that referenced this issue Jun 29, 2016
@unknwon
Copy link
Member

unknwon commented Jun 29, 2016

Example:

cfg, err := ini.InsensitiveLoad("filename")
//...

// sec1 and sec2 are the exactly same section object
sec1, err := cfg.GetSection("Section")
sec2, err := cfg.GetSection("SecTIOn")

// key1 and key2 are the exactly same key object
key1, err := cfg.GetKey("Key")
key2, err := cfg.GetKey("KeY")

@unknwon unknwon closed this as completed Jul 8, 2016
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

No branches or pull requests

2 participants