xdg

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2020 License: MIT Imports: 4 Imported by: 26

README

xdg

Light weight helper functions in golang to get config, data and cache files according to the XDG Base Directory Specification

Go Report Card Coverage Status

Install

go get github.com/kyoh86/xdg

LICENSE

MIT License

This is distributed under the MIT License.

Documentation

Overview

Package xdg Light weight helper functions in golang to get config, data and cache files according to the XDG Base Directory Specification

Index

Constants

View Source
const (
	// ConfigHomeEnv is the name of the environment variable holding a user configuration directory path.
	ConfigHomeEnv = "XDG_CONFIG_HOME"
	// ConfigDirsEnv is the name of the environment variable holding system configuration directory paths.
	ConfigDirsEnv = "XDG_CONFIG_DIRS"
)
View Source
const (
	// DataHomeEnv is the name of the environment variable holding a user data directory path.
	DataHomeEnv = "XDG_DATA_HOME"
	// DataDirsEnv is the name of the environment variable holding system data directory paths.
	DataDirsEnv = "XDG_DATA_DIRS"
)
View Source
const (
	// DesktopDirEnv is the name of the environment variable holding a user desktop directory path.
	DesktopDirEnv = "XDG_DESKTOP_DIR"
	// DownloadDirEnv is the name of the environment variable holding a user download directory path.
	DownloadDirEnv = "XDG_DOWNLOAD_DIR"
	// DocumentsDirEnv is the name of the environment variable holding a user documents directory path.
	DocumentsDirEnv = "XDG_DOCUMENTS_DIR"
	// MusicDirEnv is the name of the environment variable holding a user music directory path.
	MusicDirEnv = "XDG_MUSIC_DIR"
	// PicturesDirEnv is the name of the environment variable holding a user pictures directory path.
	PicturesDirEnv = "XDG_PICTURES_DIR"
	// VideosDirEnv is the name of the environment variable holding a user videos directory path.
	VideosDirEnv = "XDG_VIDEOS_DIR"
	// TemplatesDirEnv is the name of the environment variable holding a user templates directory path.
	TemplatesDirEnv = "XDG_TEMPLATES_DIR"
	// PublicShareDirEnv is the name of the environment variable holding a user public share directory path.
	PublicShareDirEnv = "XDG_PUBLICSHARE_DIR"
)
View Source
const (
	// CacheHomeEnv is the name of the environment variable holding a cache directory path.
	CacheHomeEnv = "XDG_CACHE_HOME"
)
View Source
const (
	// RuntimeDirEnv is the name of the environment variable holding a runtime directory path.
	RuntimeDirEnv = "XDG_RUNTIME_DIR"
)

Variables

View Source
var ErrNotFound = errors.New("not found")

ErrNotFound indicates that a file cannot be found in any directory.

Functions

func AllConfigDirs

func AllConfigDirs() []string

AllConfigDirs returns all XDG configuration directories.

func AllDataDirs

func AllDataDirs() []string

AllDataDirs returns all XDG data directories.

func CacheHome

func CacheHome() string

CacheHome returns a XDG cache directory (XDG_CACHE_HOME).

func ConfigDirs

func ConfigDirs() []string

ConfigDirs returns system XDG configuration directories (XDG_CONFIG_DIRS).

func ConfigHome

func ConfigHome() string

ConfigHome returns a user XDG configuration directory (XDG_CONFIG_HOME).

func DataDirs

func DataDirs() []string

DataDirs returns system XDG data directories (XDG_DATA_DIRS).

func DataHome

func DataHome() string

DataHome returns a user XDG data directory (XDG_DATA_HOME).

func DesktopDir added in v1.2.0

func DesktopDir() string

func DocumentsDir added in v1.2.0

func DocumentsDir() string

func DownloadDir added in v1.2.0

func DownloadDir() string

func FindCacheFile

func FindCacheFile(rel ...string) (string, error)

FindCacheFile finds a file from the XDG data directory. If one cannot be found, an error `ErrNotFound` be returned.

func FindConfigFile

func FindConfigFile(rel ...string) (string, error)

FindConfigFile finds a file from the XDG configuration directory. If one cannot be found, an error `ErrNotFound` be returned.

func FindDataFile

func FindDataFile(rel ...string) (string, error)

FindDataFile finds a file from the XDG data directory. If one cannot be found, an error `ErrNotFound` be returned.

func FindRuntimeFile

func FindRuntimeFile(rel ...string) (string, error)

FindRuntimeFile finds a file from the XDG runtime directory. If one cannot be found, an error `ErrNotFound` be returned.

func MusicDir added in v1.2.0

func MusicDir() string

func PicturesDir added in v1.2.0

func PicturesDir() string

func PublicShareDir added in v1.2.0

func PublicShareDir() string

func RuntimeDir

func RuntimeDir() string

RuntimeDir returns XDG runtime directory.

func TemplatesDir added in v1.2.0

func TemplatesDir() string

func VideosDir added in v1.2.0

func VideosDir() string

Types

This section is empty.

Jump to

Keyboard shortcuts

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