You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Will Dixon 4ba9e1eb29 Add FreeBSD and OpenBSD Support 6 months ago
.gitignore Adding OS specific tests and added Travis CI 2 years ago
.travis.yml Add Go Mod support 7 months ago
LICENSE Create LICENSE 2 years ago
README.md Add FreeBSD and OpenBSD Support 5 months ago
appveyor.yml Add Go Mod support 7 months ago
go.mod Add Go Mod support 7 months ago
go.sum Add Go Mod support 7 months ago
xdg.go Fix the ordering in which it queries for a file. 7 months ago
xdg_bsd.go Add FreeBSD and OpenBSD Support 5 months ago
xdg_bsd_test.go Add FreeBSD and OpenBSD Support 5 months ago
xdg_darwin.go App Data and Configs should follow Mac standards 7 months ago
xdg_darwin_test.go App Data and Configs should follow Mac standards 7 months ago
xdg_linux.go Golang has a constant for PathListSeperator 2 years ago
xdg_linux_test.go Fix test by reseting the defaulter variable 2 years ago
xdg_test.go Renamed two test I forgot to change the name of 2 years ago
xdg_windows.go Golang has a constant for PathListSeperator 2 years ago
xdg_windows_test.go Fix test by reseting the defaulter variable 2 years ago

README.md

XDG Build status Build Status Go Report Card GoDoc codecov

A cross platform package that tries to follow XDG Standard when possible. Since XDG is linux specific, I am only able to follow standards to the T on linux. But for the other operating systems I am finding similar best practice locations for the files.

Locations Per OS

The following table shows what is used if the envrionment variable is not set. If the variable is set then this package uses that. Linux follows the default standards. Mac does when it comes to the home directory but for system wide it uses the standard /Library/Application Support. As for Windows, the variable defaults are just other environment variables set up by the operation system.

When creating XDG application the Vendor and Application names are appeneded to the end of the path to keep projects unique.

Linux(and BSD) Mac Windows
XDG_DATA_DIRS [/usr/local/share, /usr/share] [/Library/Application Support] %PROGRAMDATA%
XDG_DATA_HOME ~/.local/share ~/Library/Application Support %APPDATA%
XDG_CONFIG_DIRS [/etc/xdg] [/Library/Application Support] %PROGRAMDATA%
XDG_CONFIG_HOME ~/.config ~/Library/Application Support %APPDATA%
XDG_CACHE_HOME ~/.cache ~/Library/Caches %LOCALAPPDATA%

Notes

  • This package does not merge files if they exist across different directories.
  • The Query methods search through the system variables, DIRS, first (when using environment variables first in the variable has presidence). It then checks home variables, HOME.
  • This package will not create any directories for you. In the standard, it states the following:

If, when attempting to write a file, the destination directory is non-existant an attempt should be made to create it with permission 0700. If the destination directory exists already the permissions should not be changed. The application should be prepared to handle the case where the file could not be written, either because the directory was non-existant and could not be created, or for any other reason. In such case it may chose to present an error message to the user.