go-conf Go 实现的轻量级的 config 库开源项目

我要开发同款
匿名用户2018年10月29日
26阅读
开发技术GO语言
所属分类Google Go、其他开发相关、程序开发
授权协议MIT

作品详情

go-conf是使用Go实现的一个轻量级的config库,参考了ozzo-config的设计,但具有更优的性能和支持动态移植配置的功能。

go-conf采用MIT开源协议。

下载安装go get github.com/syyongx/cconf功能

从配置文件中读取配置,默认支持JSON格式文件,提供了接口,也可非常方便地扩展支持其他格式配置文件;

可将一个go的结构体数据直接动态移植到config实例中;

不需要提前构建结构体就可以直接获取你想要的数据;

快速开始import github.com/syyongx/cconffunc main() {    c := cconf.New()    age := c.GetInt("age", 18)    name := c.Get("name").(string)    c.Set("email", "default@default.com")    email := c.GetString("email")}接口New() *ConfRegisterLoadFunc(typ string, fn loadFunc)Load(files ...string) errorLoadWithPattern(pattern string) errorSet(key string, val interface{}) errorGet(key string, def ...interface{}) interface{}GetString(key string, def ...string) stringGetInt(key string, def ...int) intGetInt64(key string, def ...int64) int64GetFloat(key string, def ...float64) float64GetBool(key string, def ...bool) boolSetStore(data ...interface{})GetStore() interface{}Register(name string, provider interface{}) errorPopulate(v interface{}, key ...string) (err error)
查看全文
声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论