~pkal/dirconf

ref: 9e3748a64ced2b04eb67167da3ec80bf088e5746 dirconf/README.md -rw-r--r-- 1.3 KiB
9e3748a6 — Philip K added initial readme 2 years ago

#dirconf

Dirconf implements Go library for a simple configuration format, that instead of storing everything in a file, uses the file system as a hierarchical key-value storage.

#Usage

Initialise a configuration object as follows:

conf, err := dirconf.Open("path/to/dir")

if err is nil, then conf shall be a valid configuration object. This can now be used to retrieve values, as the following examples demonstrate.

  • Query a Boolean value with the key active:

      active, err := conf.Bool("active")
    

    The variable active will then and only then be true, if the file path/to/dir/active exists, regardless of it's content.

  • Get the integer value size from the group buffer:

      i, err := conf.Int64("buffer", "size")
    

    in the file system, this would parse the contents of the file /path/to/dir/buffer/size, as an Integer. If it is not an Integer, err shall equal dirconf.ErrWrongType.

  • Receive a file object as *os.File from the key profile.jpg in the group user, subgroup "hans":

      f, err := conf.File("user", "hans", "profile.jpg")
    

    If no such file exists, err shall equal dirconf.ErrNoSuchKey.

Dirconf is distributed under CC0. See LICENSE for more details