Go 实现的轻量级的 config 库 go-conf

码农软件 · 软件分类 · 其他开发相关 · 2019-10-16 09:29:24

软件介绍

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

go-conf 采用 MIT 开源协议。

下载安装

go get github.com/syyongx/cconf

功能

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

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

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

快速开始

import github.com/syyongx/cconf

func 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() *Conf
RegisterLoadFunc(typ string, fn loadFunc)
Load(files ...string) error
LoadWithPattern(pattern string) error

Set(key string, val interface{}) error
Get(key string, def ...interface{}) interface{}
GetString(key string, def ...string) string
GetInt(key string, def ...int) int
GetInt64(key string, def ...int64) int64
GetFloat(key string, def ...float64) float64
GetBool(key string, def ...bool) bool

SetStore(data ...interface{})
GetStore() interface{}

Register(name string, provider interface{}) error
Populate(v interface{}, key ...string) (err error)

本文地址:https://codercto.com/soft/d/16866.html

iPhone开发实战

iPhone开发实战

2009-10 / 69.00元

《iPhone开发实战》全面探讨了iPhone平台的两种编程方式——Web开发和SDK编程。全书结合示例对这两种编程方式的基本流程、基本原理和基本原则给出了详细而通俗的讲解。在Web开发方面,分别介绍了三个iPhone Web库,即WebKit、iUI和Canvas,并讨论了Web开发环境Dashcode,最后阐述Web应用程序的调试。在SDK开发方面,详细描述其各种组件和功能,包括Xcode、I......一起来看看 《iPhone开发实战》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具