github.com/insionng/yougam@v0.0.0-20170714101924-2bc18d833463/libraries/goconfig/README.md (about) 1 goconfig [](https://drone.io/github.com/Unknwon/goconfig/latest) [](http://gowalker.org/github.com/Unknwon/goconfig) [](http://gocover.io/github.com/Unknwon/goconfig) 2 ======== 3 4 [中文文档](README_ZH.md) 5 6 Code Convention: based on [Go Code Convention](https://github.com/Unknwon/go-code-convention). 7 8 ## About 9 10 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. 11 12 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. 13 14 ## Features 15 16 - It simplified operation processes, easy to use and undersatnd; therefore, there are less chances to have errors. 17 - 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. 18 - It supports read recursion sections. 19 - It supports auto increment of key. 20 - It supports **READ** and **WRITE** configuration file with comments each section or key which all the other parsers don't support!!!!!!! 21 - 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. 22 - It's able to load multiple files to overwrite key values. 23 24 ## Installation 25 26 go get github.com/Unknwon/goconfig 27 28 Or 29 30 gopm get github.com/Unknwon/goconfig 31 32 ## API Documentation 33 34 [Go Walker](http://gowalker.org/github.com/Unknwon/goconfig). 35 36 ## Example 37 38 Please see [conf.ini](testdata/conf.ini) as an example. 39 40 ### Usage 41 42 - Function `LoadConfigFile` load file(s) depends on your situation, and return a variable with type `ConfigFile`. 43 - `GetValue` gives basic functionality of getting a value of given section and key. 44 - Methods like `Bool`, `Int`, `Int64` return corresponding type of values. 45 - Methods start with `Must` return corresponding type of values and returns zero-value of given type if something goes wrong. 46 - `SetValue` sets value to given section and key, and inserts somewhere if it does not exist. 47 - `DeleteKey` deletes by given section and key. 48 - Finally, `SaveConfigFile` saves your configuration to local file system. 49 - Use method `Reload` in case someone else modified your file(s). 50 - Methods contains `Comment` help you manipulate comments. 51 52 ## More Information 53 54 - All characters are CASE SENSITIVE, BE CAREFULL! 55 56 ## Credits 57 58 - [goconf](http://code.google.com/p/goconf/) 59 - [robfig/config](https://github.com/robfig/config) 60 - [Delete an item from a slice](https://groups.google.com/forum/?fromgroups=#!topic/golang-nuts/lYz8ftASMQ0) 61 62 ## License 63 64 This project is under Apache v2 License. See the [LICENSE](LICENSE) file for the full license text.