Skip to content
/ xdg Public

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

License

Notifications You must be signed in to change notification settings

tzrikka/xdg

Repository files navigation

Cross-Platform XDG Base Directories

Go Reference Code Wiki 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

Usage

Functions: https://pkg.go.dev/github.com/tzrikka/xdg#pkg-functions

Examples: https://pkg.go.dev/github.com/tzrikka/xdg#pkg-examples

Constants: https://pkg.go.dev/github.com/tzrikka/xdg#pkg-constants

Default Paths

Unix & macOS

Env Var Unix macOS
XDG_CACHE_HOME $HOME/.cache $HOME/Library/Caches
XDG_CONFIG_HOME $HOME/.config $HOME/.config
XDG_CONFIG_DIRS /etc/xdg $HOME/Library/Application Support
/Library/Application Support
/etc/xdg
XDG_DATA_HOME $HOME/.local/share $HOME/Library/Application Support
XDG_DATA_DIRS /usr/local/share /Library/Application Support
/usr/share $HOME/.local/share
/usr/local/share
/usr/share
XDG_STATE_HOME $HOME/.local/state $HOME/Library/Application Support

Microsoft Windows

XDG Env Var Known Folder Windows Env Var
XDG_CACHE_HOME FOLDERID_LocalAppData %LOCALAPPDATA%
XDG_CONFIG_HOME FOLDERID_RoamingAppData %APPDATA%
XDG_CONFIG_DIRS FOLDERID_ProgramData %ALLUSERSPROFILE%
or %ProgramData%
XDG_DATA_HOME FOLDERID_LocalAppData %LOCALAPPDATA%
XDG_DATA_DIRS FOLDERID_ProgramData %ALLUSERSPROFILE%
or %ProgramData%
XDG_STATE_HOME FOLDERID_LocalAppData %LOCALAPPDATA%

About

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

Topics

Resources

License

Stars

Watchers

Forks

Languages