Handling configuration files
When it comes to configuration files and parsing them, you have a lot of options, from simple to complicated.
We could, of course, simply store what we want in JSON, but that format is a little tricky to work directly for humans—it will require escaping characters and so on, which makes it vulnerable to errors.
Instead, we'll keep things simple by using a standard ini config
file library in gcfg, which handles gitconfig
files and traditional, old school .ini
format, as shown in the following code snippet:
[revisions] count = 2 revisionsuffix = .rev lockfiles = false [logs] rotatelength = 86400 [alarms] emails = sysadmin@example.com,ceo@example.com
Note
You can find gcfg at https://code.google.com/p/gcfg/.
Essentially, this ...
Get Go: Building Web Applications now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.