xdg

package module
v0.0.0-...-2d466d6 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2015 License: MIT Imports: 4 Imported by: 0

README

xdg

GoDoc

A small utility library to easily get the XDG Base Directory specification's directories in a cross-platform manner. Windows works!

It does this by making no attempt to use %APPDATA% or the like, simply using the user's home directory.

Documentation

Overview

Package xdg helps you respect the XDG Base Directory spec

Example
package main

import (
	"fmt"
	"path/filepath"

	"github.com/tehbilly/xdg"
)

func main() {
	// Each of these will be absolute paths to the equivalient of ~/.config/my-cool-app
	// unless the appropriate environment variables are set.

	// Windows: C:\Users\JohnDoe\.config\my-cool-app
	// Others:  /home/JohnDoe/.config/my-cool-app

	confDir := filepath.Join(xdg.ConfigHome(), "my-cool-app")
	dataDir := filepath.Join(xdg.ConfigHome(), "my-cool-app")

	fmt.Println("My config dir:", confDir)
	fmt.Println("My data dir:", dataDir)
}

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func CacheHome

func CacheHome() string

CacheHome returns either the directory specified by the XDG_CACHE_HOME environment variable, or ~/.cache

func ConfigDirs

func ConfigDirs() []string

ConfigDirs returns either the directories specified by the XDG_CONFIG_DIRS environment variable, or OS-specific defaults.

func ConfigHome

func ConfigHome() string

ConfigHome returns either the directory specified by the XDG_CONFIG_HOME environment variable, or ~/.config

func DataDirs

func DataDirs() []string

DataDirs returns either the directories specified by the XDG_DATA_DIRS environment variable, or OS-specific defaults.

func DataHome

func DataHome() string

DataHome returns either the directory specified by the XDG_DATA_HOME environment variable, or ~/.local/share

func RuntimeDir

func RuntimeDir() string

RuntimeDir returns either the directory specified by the XDG_RUNTIME_DIR environment variable, or the OS-specific version of /tmp. There are no other sane defaults.

Types

This section is empty.

Jump to

Keyboard shortcuts

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