Config
Package Config was a Configuration file parser for INI format
Package config is a concise, comment-enabled go Language profile parser, similar to the INI file under Windows.
The configuration file form is [section]
composed of a segment, the internal use of name=value
key-value pairs
If you specify a segment node, the default is placed [default]
in the segment named.
"#" is the beginning of the comment and can be placed in any single row.
Installation
go get github.com/lxmgo/config
Example
Please view the Conf.ini file as an example of use
Usage specifications
Sample configuration file:
[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
To load a configuration file:
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
More information
- All character parsing is used in lowercase!
Source
Https://github.com/lxmgo/config
The Go Language profile parser, similar to the INI file under Windows.