4
This is `go-xdg`, a little library to help you use the `XDG`
5
[base directory spec](http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html).
7
(There are other `XDG` specs, that might get included in time. Patches welcome.)
12
Let's say you are writing an app called “frobz”. It has a config file
13
and a sqlite database. You'd do something like this:
15
configFileName, err := xdg.Config.Find("frobz/config.txt")
17
// a config file exists! load it...
19
dbFileName, err := xdg.Data.Ensure("frobz/frobz.db")
20
// now the file and all its directories exist; it's up to you to
21
// determine if it's empty, etc.
27
Both `Find` and `Ensure` take a `resource` to construct the path they return.
29
A resource is usually an application name (or a well-known shared resource
30
pool name, such as `icons`), followed by a filename. However nothing in the
31
standard nor in this library limits you to that; you may store e.g. your
32
application's configuration in just `$XDG_CONFIG_HOME/application.conf` (in
33
which case the "resource" here would be just `application.conf`), or in a
34
sub-directory of an application-specific directory.
39
BSD simplified, © John R. Lenton, blah blah.