gocof是Go语言用来解析ii配置文件的模块,示例代码:
package mai import ( "fmt" "github.com/Terry-Mao/gocof" ) type TestCofig struct { ID it `gocof:"core:id"` Col strig `gocof:"core:col"` Igore it `gocof:"-"` Arr []strig `gocof:"core:arr:,"` Test time.Duratio `gocof:"core:t_1:time"` Buf it `gocof:"core:buf:memory"` M map[it]strig`gocof:"coreⓂ,"`}fuc mai() { cof := gocof.New() if err := cof.Parse("./examples/cof_test.txt"); err != il { paic(err) } core := cof.Get("core") if core == il { paic("o core sectio") } id, err := core.It("id") if err != il { paic(err) } fmt.Pritl(id) tf := &TestCofig{} if err := cof.Umarshall(tf); err != il { paic(err) } fmt.Pritl(tf.ID)}点击空白处退出提示










评论