GithubHelp home page GithubHelp logo

hagbei / configx Goto Github PK

View Code? Open in Web Editor NEW

This project forked from unknwon/goconfig

0.0 0.0 0.0 137 KB

Package goconfig is a fully functional and comments-support configuration file (.ini) parser.

License: Apache License 2.0

Go 100.00%

configx's Introduction

关于

包 configx 是一个易于使用,支持注释的 Go 语言配置文件解析器,该文件的书写格式和 Windows 下的 INI 文件一样。

配置文件由形为 [section] 的节构成,内部使用 name:valuename=value 这样的键值对;每行开头和尾部的空白符号都将被忽略;如果未指定任何节,则会默认放入名为 DEFAULT 的节当中;可以使用 “;” 或 “#” 来作为注释的开头,并可以放置于任意的单独一行中。

特性

  • 简化流程,易于理解,更少出错。
  • 提供与 Windows API 一模一样的操作方式。
  • 支持读取递归节。
  • 支持自增键名。
  • 支持对注释的 操作,其它所有解析器都不支持!!!!
  • 可以直接返回 bool, float64, int, int64 和 string 类型的值,如果使用 “Must” 开头的方法,则一定会返回这个类型的一个值而不返回错误,如果错误发生则会返回零值。
  • 支持加载多个文件来重写值。

安装

go get github.com/hagbei/configx

gopm get github.com/hagbei/configx

API 文档

Go Walker.

示例

请查看 conf.ini 文件作为使用示例。

用例

  • 函数 LoadConfigFile 加载一个或多个文件,然后返回一个类型为 ConfigFile 的变量。
  • 函数 LoadConfigHttp 加载一个或多个网络文件,然后返回一个类型为 ConfigFile 的变量。
  • 函数 Reload 可以重载您的配置文件。
  • GetValue 可以简单的获取某个值。
  • BoolIntInt64 这样的方法会直接返回指定类型的值。
  • Must 开头的方法不会返回错误,但当错误发生时会返回零值。
  • SetValue 可以设置某个值。
  • DeleteKey 可以删除某个键。
  • 最后,SaveConfigFile 可以保持您的配置到本地文件系统。

更多信息

  • 所有字符都是大小写敏感的!

授权许可

本项目采用 Apache v2 开源授权许可证,完整的授权说明已放置在 LICENSE 文件中。

configx's People

Contributors

unknwon avatar admpub avatar ncw avatar slene avatar codelingoteam avatar hagbei avatar klauspost avatar orthographic-pedant 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.