Skip to content

xdg #

xdg implements the XDG Base Directory Specification (version 0.8) by the Free Desktop organisation (freedesktop.org). The full specification can be found on https://specifications.freedesktop.org/basedir-spec/basedir-spec-0.8.html.

The specification specifies where applications should look for files, depending on their use-case. All these locations can be set using environment variables.

fn cache_home #

fn cache_home() string

cache_home is the base directory for user-specific non-essential data files.
The environment variable $XDG_CACHE_HOME controls the return value of this function. When the variable is either not set or empty, a default equal to $HOME/.cache is returned.

fn config_dirs #

fn config_dirs() []string

config_dirs is the preference-ordered set of base directories to search for configuration files in addition to the $XDG_CONFIG_HOME base directory.
The environment variable $XDG_CACHE_HOME controls the return value of this function. When the variable is either not set or empty, a default equal to /etc/xdg is returned.

fn config_home #

fn config_home() string

config_home is the base directory for user-specific configuration files.
The environment variable $XDG_CONFIG_HOME controls the return value of this function. When the variable is either not set or empty, a default equal to $HOME/.config is returned.

fn data_dirs #

fn data_dirs() []string

data_dirs defines the preference-ordered set of base directories to search for data files in addition to the $XDG_DATA_HOME base directory. If $XDG_DATA_DIRS is either not set or empty, a value equal to /usr/local/share/:/usr/share/ should be used.

fn data_home #

fn data_home() string

data_home is the base directory for user-specific date files.
The environment variable $XDG_DATA_HOME controls the return value of this function. When the variable is either not set or empty, a default equal to $HOME/.local/share is returned.

fn runtime_dir #

fn runtime_dir() ?string

$XDG_RUNTIME_DIR defines the base directory relative to which user-specific non-essential runtime files and other file objects (such as sockets, named pipes, ...) should be stored. When the variable is either not set or empty, no default value is returned (the return value is optional).

fn state_home #

fn state_home() string

state_home is the base directory for user-specific state files.
The environment variable $XDG_STATE_HOME controls the return value of this function. When the variable is either not set or empty, a default equal to $HOME/.local/state is returned.