Go语言配置文件解析器 类似于Windows下的INI文件.
Package config is a Configuration file parser for INI format
包 config 是一个简洁方的,支持注释的Go语言配置文件解析器,类似于Windows下的INI文件.
配置文件形式为[section] 的段构成, 内部使用 name=value键值对
如果为指定段节点,则默认放入名为[default]的段当中.
“#”为注释的开头,可以放置于任意的单独一行中.
请查看 conf.ini 文件作为使用示例
使用规范示例配置文件:
[DEFAULT] host = act.wiki port = 8080 f64 = 64.1 [mysql] host = 127.0.0.1 [mongodb] host = 127.0.0.2 [redis] host = 127.0.0.3 push_key = key1,key2,key3,... [memcache] host = 127.0.0.4加载配置文件:
config, err := NewConfig('testdata/testini.ini') c.Int('port') // result is int 8080 c.Int64('port') // result is int64 8080 c.Float64('f64') // result is float64 64.1 c.String('host') // result is string 'act.wiki' c.String('mysql.host') // result is string '127.0.0.1' c.String('redis.host') // result is string '127.0.0.3' c.Strings('redis.key') // result is []string{'key1','key2','key3',...} config APIS: String(key string) string Strings(key string) []string Bool(key string) (bool, error) Int(key string) (int, error) Int64(key string) (int64, error) Float64(key string) (float64,error) Set(key string, value string) error 更多信息 所有字符解析均使用小写的! 源码https://github.com/lxmgo/config
相关热词: Go语言
本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!
本文地址: https://v30.fanwenzhu.com/jiaob/go/9844.shtml
相关文章
热门TAG
win10 ecshop 主机 阿里云 解决 配置 C# C++ 解析 SQL语句 命令 Go语言 方法 CSS3 HTML5 CSS win7 MSSQL 服务器配置 IIS7.5 IIS7 IIS6 IIS CentOS 7 Linux oracle数据库 oracle phpcms discuz discuz教程最新文章
-
Lisp进修Windows下面的开拓情
时间:2021-01-12
-
Lisp进修Windows下面的开拓情
时间:2021-01-12
-
为Go语言GC正名-2秒到1毫
时间:2020-12-27
-
go语言初探 一个helloworld编
时间:2020-12-27
热门文章
-
为Go语言GC正名-2秒到1毫秒的演变史
时间:2020-12-27
-
Lisp进修Windows下面的开拓情况搭建
时间:2021-01-12
-
Lisp进修Windows下面的开拓情况搭建
时间:2021-01-12
-
go语言初探 一个helloworld编译出来有2.2M!
时间:2020-12-27
