ini: do not outout back quotes if IgnoreInlineComment enabled (#99)

This commit is contained in:
Unknwon
2017-05-18 04:52:39 -04:00
parent 79f45f0fe8
commit 36da989cdc
2 changed files with 9 additions and 2 deletions
+2 -2
View File
@@ -37,7 +37,7 @@ const (
// Maximum allowed depth when recursively substituing variable names.
_DEPTH_VALUES = 99
_VERSION = "1.27.1"
_VERSION = "1.27.2"
)
// Version returns current package version literal.
@@ -504,7 +504,7 @@ func (f *File) WriteToIndent(w io.Writer, indent string) (n int64, err error) {
// In case key value contains "\n", "`", "\"", "#" or ";"
if strings.ContainsAny(val, "\n`") {
val = `"""` + val + `"""`
} else if strings.ContainsAny(val, "#;") {
} else if !f.options.IgnoreInlineComment && strings.ContainsAny(val, "#;") {
val = "`" + val + "`"
}
if _, err = buf.WriteString(equalSign + val + LineBreak); err != nil {
+7
View File
@@ -215,6 +215,13 @@ key2=value #comment2`))
So(cfg.Section("").Key("key1").String(), ShouldEqual, `value ;comment`)
So(cfg.Section("").Key("key2").String(), ShouldEqual, `value #comment2`)
var buf bytes.Buffer
cfg.WriteTo(&buf)
So(buf.String(), ShouldEqual, `key1 = value ;comment
key2 = value #comment2
`)
})
Convey("Load with boolean type keys", t, func() {