harbor/vendor/github.com/Unknwon/goconfig
2016-02-19 13:01:58 +08:00
..
testdata switch to /vendor, remove docker/distribution docker/libtrust go-sql-driver/mysql, and update Dockerfile to use go get to download these packages. 2016-02-19 13:01:58 +08:00
.gitignore switch to /vendor, remove docker/distribution docker/libtrust go-sql-driver/mysql, and update Dockerfile to use go get to download these packages. 2016-02-19 13:01:58 +08:00
conf.go switch to /vendor, remove docker/distribution docker/libtrust go-sql-driver/mysql, and update Dockerfile to use go get to download these packages. 2016-02-19 13:01:58 +08:00
goconfig_test.go switch to /vendor, remove docker/distribution docker/libtrust go-sql-driver/mysql, and update Dockerfile to use go get to download these packages. 2016-02-19 13:01:58 +08:00
LICENSE switch to /vendor, remove docker/distribution docker/libtrust go-sql-driver/mysql, and update Dockerfile to use go get to download these packages. 2016-02-19 13:01:58 +08:00
read.go switch to /vendor, remove docker/distribution docker/libtrust go-sql-driver/mysql, and update Dockerfile to use go get to download these packages. 2016-02-19 13:01:58 +08:00
README_ZH.md switch to /vendor, remove docker/distribution docker/libtrust go-sql-driver/mysql, and update Dockerfile to use go get to download these packages. 2016-02-19 13:01:58 +08:00
README.md switch to /vendor, remove docker/distribution docker/libtrust go-sql-driver/mysql, and update Dockerfile to use go get to download these packages. 2016-02-19 13:01:58 +08:00
write.go switch to /vendor, remove docker/distribution docker/libtrust go-sql-driver/mysql, and update Dockerfile to use go get to download these packages. 2016-02-19 13:01:58 +08:00

goconfig Build Status Go Walker

中文文档

IMPORTANT

  • This library is under bug fix only mode, which means no more features will be added.
  • I'm continuing working on better Go code with a different library: ini.

About

Package goconfig is a easy-use, comments-support configuration file parser for the Go Programming Language, which provides a structure similar to what you would find on Microsoft Windows INI files.

The configuration file consists of sections, led by a [section] header and followed by name:value or name=value entries. Note that leading whitespace is removed from values. The optional values can contain format strings which refer to other values in the same section, or values in a special DEFAULT section. Comments are indicated by ";" or "#"; comments may begin anywhere on a single line.

Features

  • It simplified operation processes, easy to use and undersatnd; therefore, there are less chances to have errors.
  • It uses exactly the same way to access a configuration file as you use Windows APIs, so you don't need to change your code style.
  • It supports read recursion sections.
  • It supports auto increment of key.
  • It supports READ and WRITE configuration file with comments each section or key which all the other parsers don't support!!!!!!!
  • It supports get value through type bool, float64, int, int64 and string, methods that start with "Must" means ignore errors and get zero-value if error occurs, or you can specify a default value.
  • It's able to load multiple files to overwrite key values.

Installation

go get github.com/Unknwon/goconfig

Or

gopm get github.com/Unknwon/goconfig

API Documentation

Go Walker.

Example

Please see conf.ini as an example.

Usage

  • Function LoadConfigFile load file(s) depends on your situation, and return a variable with type ConfigFile.
  • GetValue gives basic functionality of getting a value of given section and key.
  • Methods like Bool, Int, Int64 return corresponding type of values.
  • Methods start with Must return corresponding type of values and returns zero-value of given type if something goes wrong.
  • SetValue sets value to given section and key, and inserts somewhere if it does not exist.
  • DeleteKey deletes by given section and key.
  • Finally, SaveConfigFile saves your configuration to local file system.
  • Use method Reload in case someone else modified your file(s).
  • Methods contains Comment help you manipulate comments.

More Information

  • All characters are CASE SENSITIVE, BE CAREFUL!

Credits

License

This project is under Apache v2 License. See the LICENSE file for the full license text.