~vtuson/scopecreator/twitter-template

« back to all changes in this revision

Viewing changes to src/go/src/launchpad.net/go-xdg/v0/README.md

  • Committer: Victor Palau
  • Date: 2015-03-11 14:24:42 UTC
  • Revision ID: vtuson@gmail.com-20150311142442-f2pxp111c8ynv232
public release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Go, XDG, go!
 
2
===========
 
3
 
 
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).
 
6
 
 
7
(There are other `XDG` specs, that might get included in time. Patches welcome.)
 
8
 
 
9
Sample usage
 
10
------------
 
11
 
 
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:
 
14
 
 
15
    configFileName, err := xdg.Config.Find("frobz/config.txt")
 
16
    if err == nil {
 
17
        // a config file exists! load it...
 
18
    }
 
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.
 
22
 
 
23
 
 
24
Resources
 
25
---------
 
26
 
 
27
Both `Find` and `Ensure` take a `resource` to construct the path they return.
 
28
 
 
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.
 
35
 
 
36
License, etc.
 
37
------------
 
38
 
 
39
BSD simplified, © John R. Lenton, blah blah.