Documentation
¶
Overview ¶
Package xdg helps you respect the XDG Base Directory spec
Example ¶
package main
import (
"fmt"
"path/filepath"
"github.com/tehbilly/xdg"
)
func main() {
// Each of these will be absolute paths to the equivalient of ~/.config/my-cool-app
// unless the appropriate environment variables are set.
// Windows: C:\Users\JohnDoe\.config\my-cool-app
// Others: /home/JohnDoe/.config/my-cool-app
confDir := filepath.Join(xdg.ConfigHome(), "my-cool-app")
dataDir := filepath.Join(xdg.ConfigHome(), "my-cool-app")
fmt.Println("My config dir:", confDir)
fmt.Println("My data dir:", dataDir)
}
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CacheHome ¶
func CacheHome() string
CacheHome returns either the directory specified by the XDG_CACHE_HOME environment variable, or ~/.cache
func ConfigDirs ¶
func ConfigDirs() []string
ConfigDirs returns either the directories specified by the XDG_CONFIG_DIRS environment variable, or OS-specific defaults.
func ConfigHome ¶
func ConfigHome() string
ConfigHome returns either the directory specified by the XDG_CONFIG_HOME environment variable, or ~/.config
func DataDirs ¶
func DataDirs() []string
DataDirs returns either the directories specified by the XDG_DATA_DIRS environment variable, or OS-specific defaults.
func DataHome ¶
func DataHome() string
DataHome returns either the directory specified by the XDG_DATA_HOME environment variable, or ~/.local/share
func RuntimeDir ¶
func RuntimeDir() string
RuntimeDir returns either the directory specified by the XDG_RUNTIME_DIR environment variable, or the OS-specific version of /tmp. There are no other sane defaults.
Types ¶
This section is empty.