当我加载文件并更改了Name字符串时,我想将conf输出到myconfig.gcfg。我应该怎么做? 示例配置:
[Span]
Name = "DuraSpan"
MySpan = 4
[Sys]
SerialName = "/dev/ttyS0"
转到代码:
import "gopkg.in/gcfg.v1"
type Config struct {
Span struct {
Name string
MySpan int
}
Sys struct{
SerialName string
}
}
var conf Config
err := gcfg.ReadFileInto(&conf, "myconfig.gcfg")
conf.Span.MySpan = 6
如何将更改写回文件?