go-cof是使用Go实现的一个轻量级的cofig库,参考了ozzo-cofig的设计,但具有更优的性能和支持动态移植配置的功能。
go-cof采用MIT开源协议。
下载安装go get github.com/syyogx/ccof功能从配置文件中读取配置,默认支持JSON格式文件,提供了接口,也可非常方便地扩展支持其他格式配置文件;
可将一个go的结构体数据直接动态移植到cofig实例中;
不需要提前构建结构体就可以直接获取你想要的数据;
快速开始import github.com/syyogx/ccoffuc mai() { c := ccof.New() age := c.GetIt("age", 18) ame := c.Get("ame").(strig) c.Set("email", "default@default.com") email := c.GetStrig("email")}接口New() *CofRegisterLoadFuc(typ strig, f loadFuc)Load(files ...strig) errorLoadWithPatter(patter strig) errorSet(key strig, val iterface{}) errorGet(key strig, def ...iterface{}) iterface{}GetStrig(key strig, def ...strig) strigGetIt(key strig, def ...it) itGetIt64(key strig, def ...it64) it64GetFloat(key strig, def ...float64) float64GetBool(key strig, def ...bool) boolSetStore(data ...iterface{})GetStore() iterface{}Register(ame strig, provider iterface{}) errorPopulate(v iterface{}, key ...strig) (err error)
评论