Skip to content

tzrikka/xdg

Repository files navigation

Cross-Platform XDG Base Directories

Go Reference Go Report Card

This package implements the XDG Base Directory Specification, with adjustments for macOS and Windows.

Supported operating systems: all Unix flavors, macOS, and Windows.

It was created with these design goals/principles:

  • Code and usage simplicity
  • Seamless handling of XDG_* environment variable changes during runtime
  • Minimal dependencies on other third-party Go packages

Installation

go get github.com/tzrikka/xdg

Default Paths

All Unix Flavors

XDG_CACHE_HOME

Operating System Path
Unix $HOME/.cache
macOS $HOME/Library/Caches

XDG_CONFIG_HOME

Operating System Path
Unix $HOME/.config
macOS $HOME/Library/Application Support

XDG_CONFIG_DIRS

Operating System Path(s)
Unix /etc/xdg
macOS /Library/Application Support
$HOME/.config
/etc/xdg

XDG_DATA_HOME

Operating System Path
Unix $HOME/.local/share
macOS $HOME/Library/Application Support

XDG_DATA_DIRS

Operating System Path(s)
Unix /usr/local/share
/usr/share
macOS /Library/Application Support
$HOME/.local/share
/usr/local/share
/usr/share

XDG_STATE_HOME

Operating System Path
Unix $HOME/.local/state
macOS $HOME/Library/Application Support

Microsoft Windows

Known folder IDs

Recognized environment variables

XDG_CACHE_HOME

Type Value
Known Folder FOLDERID_LocalAppData
Env Var %LOCALAPPDATA%

XDG_CONFIG_HOME

Type Value
Known Folder FOLDERID_RoamingAppData
Env Var %APPDATA%

XDG_CONFIG_DIRS

Type Value
Known Folder FOLDERID_ProgramData
Env Var %ALLUSERSPROFILE% or %ProgramData%

XDG_DATA_HOME

Type Value
Known Folder FOLDERID_LocalAppData
Env Var %LOCALAPPDATA%

XDG_DATA_DIRS

Type Value
Known Folder FOLDERID_ProgramData
Env Var %ALLUSERSPROFILE% or %ProgramData%

XDG_STATE_HOME

Type Value
Known Folder FOLDERID_LocalAppData
Env Var %LOCALAPPDATA%

About

Cross-platform implementation in Go of the XDG Base Directory Specification

Topics

Resources

License

Stars

Watchers

Forks

Languages