README.md
1goconfig [![Go Walker](http://gowalker.org/api/v1/badge)](http://gowalker.org/github.com/Unknwon/goconfig)
2========
3
4[中文文档](README_ZH.md)
5
6**IMPORTANT**
7
8- This library is under bug fix only mode, which means no more features will be added.
9- I'm continuing working on better Go code with a different library: [ini](https://github.com/go-ini/ini).
10
11## About
12
13Package 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.
14
15The 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.
16
17## Features
18
19- It simplified operation processes, easy to use and undersatnd; therefore, there are less chances to have errors.
20- 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.
21- It supports read recursion sections.
22- It supports auto increment of key.
23- It supports **READ** and **WRITE** configuration file with comments each section or key which all the other parsers don't support!!!!!!!
24- 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.
25- It's able to load multiple files to overwrite key values.
26
27## Installation
28
29 go get github.com/unknwon/goconfig
30
31## API Documentation
32
33[Go Walker](http://gowalker.org/github.com/unknwon/goconfig).
34
35## Example
36
37Please see [conf.ini](testdata/conf.ini) as an example.
38
39### Usage
40
41- Function `LoadConfigFile` load file(s) depends on your situation, and return a variable with type `ConfigFile`.
42- `GetValue` gives basic functionality of getting a value of given section and key.
43- Methods like `Bool`, `Int`, `Int64` return corresponding type of values.
44- Methods start with `Must` return corresponding type of values and returns zero-value of given type if something goes wrong.
45- `SetValue` sets value to given section and key, and inserts somewhere if it does not exist.
46- `DeleteKey` deletes by given section and key.
47- Finally, `SaveConfigFile` saves your configuration to local file system.
48- Use method `Reload` in case someone else modified your file(s).
49- Methods contains `Comment` help you manipulate comments.
50- `LoadFromReader` allows loading data without an intermediate file.
51- `SaveConfigData` added, which writes configuration to an arbitrary writer.
52- `ReloadData` allows to reload data from memory.
53
54Note that you cannot mix in-memory configuration with on-disk configuration.
55
56## More Information
57
58- All characters are CASE SENSITIVE, BE CAREFUL!
59
60## Credits
61
62- [goconf](http://code.google.com/p/goconf/)
63- [robfig/config](https://github.com/robfig/config)
64- [Delete an item from a slice](https://groups.google.com/forum/?fromgroups=#!topic/golang-nuts/lYz8ftASMQ0)
65
66## License
67
68This project is under Apache v2 License. See the [LICENSE](LICENSE) file for the full license text.
69