userdirs

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 3 Imported by: 4 modules, 8 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package userdirs answers where a user's config and data folders are for a given home. Each function takes the home folder the caller resolves for (a test's temporary home, another account's profile).

An environment value is used only when home is this process's own home (os.UserHomeDir, compared after filepath.Clean and, on Windows, case-folded) and the value is an absolute path; the XDG Base Directory spec says to ignore a relative one. Otherwise the default under home is returned. home == "" returns "" for every function, since the environment describes only the real home: the caller turns "" into an error. No function reads runtime.GOOS: the caller picks the layout it is resolving.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppData

func AppData(home string) string

AppData is %APPDATA%, else home/AppData/Roaming.

func ConfigHome

func ConfigHome(home string) string

ConfigHome is $XDG_CONFIG_HOME, else home/.config.

func DataHome

func DataHome(home string) string

DataHome is $XDG_DATA_HOME, else home/.local/share.

func FlatpakApp

func FlatpakApp(home, appID string) string

FlatpakApp is home/.var/app/<appID>, the per-user folder Flatpak gives each app.

func HostConfigHome

func HostConfigHome(home string) string

HostConfigHome and HostDataHome are the host user's folders, for reading another program's files. Outside a Flatpak they equal ConfigHome and DataHome. Inside one (flatpak.Inside) Flatpak points XDG_CONFIG_HOME and XDG_DATA_HOME at the app's own ~/.var/app folder, so those are skipped; HOST_XDG_CONFIG_HOME and HOST_XDG_DATA_HOME, which Flatpak sets to the host's custom folders, are read under the same rule, else the default under home is returned.

func HostDataHome

func HostDataHome(home string) string

HostDataHome is HostConfigHome for the data home.

func LocalAppData

func LocalAppData(home string) string

LocalAppData is %LOCALAPPDATA%, else home/AppData/Local.

Types

This section is empty.

Jump to

Keyboard shortcuts

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