xdg

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2019 License: MIT Imports: 4 Imported by: 33

README

xdg

Go Report Card CircleCI Coverage Status

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

Install

go get github.com/kyoh86/xdg

Usage

License

MIT License

This is distributed under the MIT License.

Documentation

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 (
	// 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 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 RuntimeDir

func RuntimeDir() string

RuntimeDir returns XDG runtime directory.

Types

This section is empty.

Jump to

Keyboard shortcuts

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