ini
ini copied to clipboard
Quoting values in written file
Describe the bug
Writing ini file from struct not allowing to quote string values.
There is the option PreserveSurroundedQuote
to keep quotes in the loadOptions but as I don't load the values from file but from struct, I cannot use that option.
My code is creating a config file that later a php code will use. The PHP specify that
If a value in the ini file contains any non-alphanumeric characters it needs to be enclosed in double-quotes (").
Is there a way that I missed to force the values to be quoted?
To Reproduce https://play.golang.org/p/TwJgeMWf6zW
Expected behavior All string values will be quoted
For context, if there is no special character in the key or value that will confuse this library later (at parsing stage), there will be no quotes added automatically.
Just to note, strings with special characters are currently getting "`" around them, that can break the configuration for other lang other than PHP as well. In my opinion the minimum should be to quote strings with escaped characters and set the quotation to double quotes as it's the most common. The ideal solution will be to add a user config option to set how to treat strings (like defining what are special characters that needs the string to be quoted and what quotation to use)
Is there a fix or work-around for the key names being wrapped in "`" ? It's breaking my code.
Is there a fix or work-around for the key names being wrapped in "`" ? It's breaking my code.
@jlagermann I am not sure if you're commenting on the right thread.
It looks like this ticket does not get much traction so I’ll close it now