xdg

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 25, 2026 License: MPL-2.0 Imports: 3 Imported by: 0

README

xdg

XDG base directory paths for Go, with macOS fallbacks.

import "github.com/flamingoosesoftwareinc/xdg"

cfg, err := xdg.ConfigHome()   // $XDG_CONFIG_HOME, $HOME/.config, or ~/Library/Application Support
Function Linux macOS
ConfigHome $XDG_CONFIG_HOME or ~/.config ~/Library/Application Support
DataHome $XDG_DATA_HOME or ~/.local/share ~/Library/Application Support
CacheHome $XDG_CACHE_HOME or ~/.cache ~/Library/Caches
StateHome $XDG_STATE_HOME or ~/.local/state ~/Library/Application Support

AppConfig, AppData, AppState and AppCache take an app name, return the corresponding subdirectory, and create it if absent.

dir, err := xdg.AppConfig("myapp")   // ~/.config/myapp, created if missing

License

MPL-2.0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppCache

func AppCache(appName string) (string, error)

AppCache returns CacheHome()/<appName>. Creates the directory if it doesn't exist.

func AppConfig

func AppConfig(appName string) (string, error)

AppConfig returns ConfigHome()/<appName>. Creates the directory if it doesn't exist.

func AppData

func AppData(appName string) (string, error)

AppData returns DataHome()/<appName>. Creates the directory if it doesn't exist.

func AppState

func AppState(appName string) (string, error)

AppState returns StateHome()/<appName>. Creates the directory if it doesn't exist.

func CacheHome

func CacheHome() (string, error)

CacheHome returns the base cache directory.

  • Linux: $XDG_CACHE_HOME or $HOME/.cache
  • macOS: $HOME/Library/Caches

func ConfigHome

func ConfigHome() (string, error)

ConfigHome returns the base config directory.

  • Linux: $XDG_CONFIG_HOME or $HOME/.config
  • macOS: $HOME/Library/Application Support

func DataHome

func DataHome() (string, error)

DataHome returns the base data directory.

  • Linux: $XDG_DATA_HOME or $HOME/.local/share
  • macOS: $HOME/Library/Application Support

func StateHome

func StateHome() (string, error)

StateHome returns the base state directory.

  • Linux: $XDG_STATE_HOME or $HOME/.local/state
  • macOS: $HOME/Library/Application Support

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL