GithubHelp home page GithubHelp logo

goini's Introduction

goini

golang parse ini config file with multistage block configuration

Features:

  • support mutil level block configuration, for example:
[level_one]
x1 = y1
x2 = y2
  [.level_two]
  m1 = n1
  m2 = n2
    [..level_three]
       s1 = t1
       s2 = t2
  • configuration comment support, and continuously blank line more than 50 parse break out support
  • support get all the <key,value> of a block with its child blocks content.
  • load the config file contents to memory once

How to apply:

  • install the code to your application:

go get github.com/tokyliu/goini

  • init the config object:

config, err := NewIniConfig(filePath)

  • get the config structed mirror to judge the config strcuted object is match your config file:

configStr := config.String()

  • get the config item value with the key:

value, exist := config.GetKeyValue(keyName)

  • get all the <key,value> pair of a block:

kvMap,exist := config.GetBlockKeyValues(blockName)

Examples:

  • sample ini config file content as below:
[family]
province = guangdong
city = shenzhen
[.brother]
name = liming
age = 87
[..son]
name = lixiaolong
age = 64
[...son]
name = limingze
age = 37
[...daughter]
name = lixiaoxiao
age = 35
[..daughter]
name = lirui
age = 62
[.sister]
name = liqiu
age = 81
[..son]
name = liumingze
age = 59
[...daughter]
name = liumeimei
age = 55
[.young_sister]
name = lixiaomei
age = 80
[..daughter]
name = zhenxiaolong
age = 57
  • use the GetKeyValue() to get the value of keyName:
value, exist := config.GetKeyValue("family.brother.son.name") // value=lixiaolong
value, exist := config.GetKeyValue("family.brother.son.son.age") // value = 37
value, exist := config.GetKeyValue("family.young_sister.daughter.name") // value = zhenxiaolong
  • use the GetBlockKeyValues to get all the <key,value> pair:
kvMap, exist := config.GetBlockKeyValues(family.young_sister) 

goini's People

Contributors

tokyliu avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.