Documentation
¶
Overview ¶
Package xdg resolves the XDG base directories and user directories: the base directories themselves, and an app's own directory under each, all read from an Env.
Index ¶
- type Env
- func (e Env) CacheDir(app string) (string, bool)
- func (e Env) CacheHome() (string, bool)
- func (e Env) ConfigDir(app string) (string, bool)
- func (e Env) ConfigDirs() []string
- func (e Env) ConfigHome() (string, bool)
- func (e Env) DataDir(app string) (string, bool)
- func (e Env) DataHome() (string, bool)
- func (e Env) RuntimeDir(app string) (string, bool)
- func (e Env) RuntimeHome() (string, bool)
- func (e Env) StateDir(app string) (string, bool)
- func (e Env) UserDir(key string) (string, bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Env ¶
Env is the environment the directories are resolved from: it maps a variable's name to its value, "" when unset, as os.Getenv does. Tests pass their own to leave the process environment alone.
func (Env) CacheDir ¶
CacheDir is app's cache directory, $XDG_CACHE_HOME/app or ~/.cache/app; false when neither variable holds an absolute path. It panics on an app that is not a single path element.
func (Env) CacheHome ¶
CacheHome is the user's cache directory itself, $XDG_CACHE_HOME or ~/.cache, where caches shared across apps live (the thumbnails); false when neither variable holds an absolute path.
func (Env) ConfigDir ¶
ConfigDir is app's configuration directory, $XDG_CONFIG_HOME/app or ~/.config/app; false when neither variable holds an absolute path. It panics on an app that is not a single path element.
func (Env) ConfigDirs ¶
ConfigDirs are the system configuration directories, most important first: the absolute entries of $XDG_CONFIG_DIRS, or /etc/xdg when it names none.
func (Env) ConfigHome ¶
ConfigHome is the user's configuration directory itself, $XDG_CONFIG_HOME or ~/.config, where configuration shared across apps lives (user-dirs.dirs); false when neither variable holds an absolute path.
func (Env) DataDir ¶
DataDir is app's data directory, $XDG_DATA_HOME/app or ~/.local/share/app; false when neither variable holds an absolute path. It panics on an app that is not a single path element.
func (Env) DataHome ¶
DataHome is the user's data directory itself, $XDG_DATA_HOME or ~/.local/share, where data shared across apps lives (the trash, the recently-used list); false when neither variable holds an absolute path.
func (Env) RuntimeDir ¶
RuntimeDir is app's runtime directory, $XDG_RUNTIME_DIR/app, for sockets and markers that live as long as the login; false when the variable holds no absolute path, as the spec defines no fallback. It panics on an app that is not a single path element.
func (Env) RuntimeHome ¶
RuntimeHome is the user's runtime directory itself, $XDG_RUNTIME_DIR; false when it holds no absolute path.
func (Env) StateDir ¶
StateDir is app's state directory, $XDG_STATE_HOME/app or ~/.local/state/app; false when neither variable holds an absolute path. It panics on an app that is not a single path element.
func (Env) UserDir ¶
UserDir is a user directory from $XDG_CONFIG_HOME/user-dirs.dirs (glib's g_get_user_special_dir): key is the name between XDG_ and _DIR (DOCUMENTS, PICTURES, ...), the value's leading $HOME expanded. It is not set, false with a nil error, when there is no config directory, no user-dirs.dirs or no line for key. Every other failure is an error: the file could not be read, or key's value is not a quoted absolute or $HOME-relative path.