unknwon / goconfig

Package goconfig is a fully functional and comments-support configuration file (.ini) parser.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

保存时ini的部分内容被添加反单引号

meilihao opened this issue · comments

info.ini内容:

[info]
temp_max=8
temp_min=2
[time]
total=3
0=0/0/0;2014-04-28 03:31;2014-04-28 18:07;0
1=0/0/0;2014-04-28 18:33;2014-04-28 21:08;0
2=0/0/0;2014-04-28 23:10;2014-04-29 01:35;0
from=2014-04-28 03:31
to=2014-05-07 00:31

cfg.SetValue("info", "temp_min", "0"),保存后内容变成:

[info]
temp_max = 8
temp_min = 0

[time]
total = 3
0 = `0/0/0;2014-04-28 03:31;2014-04-28 18:07;0`
1 = `0/0/0;2014-04-28 18:33;2014-04-28 21:08;0`
2 = `0/0/0;2014-04-28 23:10;2014-04-29 01:35;0`
from = `2014-04-28 03:31`
to = `2014-05-07 00:31`

发现部分内容被添加上反单引号,请问这是怎么回事,还有要如何避免?

包含 : " 等字符的值会被自动增加反引号避免下次读取的时候出现歧义。。这不是bug。。读取到内存时候也会被剔除。。和你原来的结果是一样的

不过没有必要性,所以我还是剔除了,感谢反馈!