The Go Language profile parser, similar to the INI file under Windows.

Source: Internet
Author: User
Tags key string

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.