Documentation
¶
Overview ¶
Package paths provides cross-platform directory resolution for application configuration, data, and cache storage.
This package abstracts platform differences in standard directory locations:
- Unix/Linux: XDG Base Directory Specification (~/.config, ~/.local/share, etc.)
- macOS: ~/Library/Application Support, ~/Library/Caches
- Windows: %APPDATA%, %LOCALAPPDATA%, %ProgramData%
All functions return absolute paths. App-specific functions (AppConfig, AppData, etc.) will create the directory if it doesn't exist.
Index ¶
- Variables
- func AppCache(appName string) (string, error)
- func AppConfig(appName string) (string, error)
- func AppData(appName string) (string, error)
- func AppRuntime(appName string) (string, error)
- func Home() (string, error)
- func SystemAppConfig(appName string) (string, error)
- func SystemConfig() (string, error)
- func UserCache() (string, error)
- func UserConfig() (string, error)
- func UserData() (string, error)
- func UserRuntime() (string, error)
Constants ¶
This section is empty.
Variables ¶
var ErrHomeNotFound = errors.New("oscompat/paths: home directory not found")
ErrHomeNotFound is returned when the user's home directory cannot be determined.
var ErrInvalidAppName = errors.New("oscompat/paths: app name cannot be empty")
ErrInvalidAppName is returned when an empty app name is provided.
Functions ¶
func AppCache ¶
AppCache returns the app-specific cache directory, creating it if needed. The directory follows platform conventions:
- Unix/Linux: ~/.cache/<appName>
- macOS: ~/Library/Caches/<appName>
- Windows: %LOCALAPPDATA%\<appName>\cache
func AppConfig ¶
AppConfig returns the app-specific configuration directory, creating it if needed. The directory follows platform conventions:
- Unix/Linux: ~/.config/<appName>
- macOS: ~/Library/Application Support/<appName>
- Windows: %APPDATA%\<appName>
func AppData ¶
AppData returns the app-specific data directory, creating it if needed. The directory follows platform conventions:
- Unix/Linux: ~/.local/share/<appName>
- macOS: ~/Library/Application Support/<appName>
- Windows: %LOCALAPPDATA%\<appName>
func AppRuntime ¶
AppRuntime returns the app-specific runtime directory, creating it if needed. This is for runtime files like sockets and PIDs that should not persist across reboots.
- Unix/Linux: $XDG_RUNTIME_DIR/<appName> or /tmp/<appName>-<uid>
- macOS: ~/Library/Application Support/<appName>/run
- Windows: %LOCALAPPDATA%\<appName>\run
func SystemAppConfig ¶
SystemAppConfig returns the system-wide app configuration directory. This requires elevated privileges to write to.
- Unix/Linux: /etc/<appName>
- Windows: %ProgramData%\<appName>
func SystemConfig ¶
SystemConfig returns the system-wide configuration directory. Returns /etc on Unix systems.
func UserCache ¶
UserCache returns the user-specific cache directory. Follows XDG Base Directory Specification: $XDG_CACHE_HOME or ~/.cache
func UserConfig ¶
UserConfig returns the user-specific configuration directory. Follows XDG Base Directory Specification: $XDG_CONFIG_HOME or ~/.config
func UserData ¶
UserData returns the user-specific data directory. Follows XDG Base Directory Specification: $XDG_DATA_HOME or ~/.local/share
func UserRuntime ¶
UserRuntime returns the user-specific runtime directory. Follows XDG Base Directory Specification: $XDG_RUNTIME_DIR or /tmp/<user>-runtime
Types ¶
This section is empty.