Extremely simple, yet efficient, file based configuration librairy
- lazily load configuration files for quick startup upon first read request (Get).
- Set will always overwrite file configuration, even if lazy loading happens after Set was called.
- get/set configuration keys
- can save modified config on disk
-
leading spaces and tabs ignored
-
blank lines are ignored
-
comment line start with # or //
-
key = value
- key has no whitespace nor tabs, it is case sensitive
- value starts at the first character following "=" until end of line. No quotes needed. Spaces surrounding the = sign are removed.
-
[ mainkey ] defines a section, where all following keys, until another section is defined, are prefixed with mainkey.
-
[] defines a section witjhout prefix. This is the default.
// this is a comment
version = 3.2.1
# this is also a comment
[ date ]
created = 1/8/2019
modified = 3/8/2019
// above will give : config.Get("date.created") --> "1/8/2019"
See examples
import ".../config"
conf := config.New("file1.conf", "file2.conf","/usr/bin/file3.conf", "~/bin/file4.conf")
// save config data, including modified values.
defer conf.Save("myconf.conf")
// access data
sn := conf.Get("surname") == ""
// set data
conf.Set("name","John Doe")