xdg

package module
v0.0.0-...-372ccc2 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2016 License: MIT Imports: 3 Imported by: 18

README

xdg-go GoDoc codebeat badge

Quickstart

If you just want OS-sensible paths.

configDirs := xdg.ConfigDirs()
dataPath := xdg.DataHome()
cachePath := xdg.CacheHome()

Alternatively you can create a context that would determine full paths for your application files.

app := xdg.App{Name: "someApp"}
configFile := app.ConfigPath("someApp.toml")
dataFile := app.DataPath("data.json")

Supported path types

This is a KISS implementation of the XDG Base Directory Specification. As of now it handles the following path types:

  • Data (XDG_DATA_*) for application-wide or user-wide data.
  • Config (XDG_CONFIG_*) for application-wide or user-wide config.
  • Cache (XDG_CACHE_*)for application-wide or user-wide cached data.

Multi-OS

The specification is Linux centric but this implementation targets more: Linux, OSX and Windows. Default values has been chosen regarding both the specification and the OS conventions. Note than you can override these values with the corresponding environment variables.

There are a lot of OSes missing but supporting them implies a good knowledge of these conventions and philosophies, contributors maybe?

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CacheHome

func CacheHome() string

func CachePath

func CachePath(file string) string

CachePath determines the full path of a cached file.

func ConfigDirs

func ConfigDirs() []string

func ConfigHome

func ConfigHome() string

func ConfigPath

func ConfigPath(file string) string

ConfigPath determines the full path of a data file.

func DataDirs

func DataDirs() []string

func DataHome

func DataHome() string

func DataPath

func DataPath(file string) string

DataPath determines the full path of a data file.

func SetName

func SetName(name string)

SetName for the default application. Used for package-wide functions.

func SystemConfigPaths

func SystemConfigPaths(file string) []string

SystemConfigPaths determines system-wide possible paths for a config file.

func SystemDataPaths

func SystemDataPaths(file string) []string

SystemDataPaths determines system-wide possible paths for a data file.

Types

type App

type App struct {
	Name string
}

App is an aggregation of XDG information for a named application. Useful to propagate app configuration.

func (App) CachePath

func (a App) CachePath(file string) string

CachePath determines the full path of a cached file.

func (App) ConfigPath

func (a App) ConfigPath(file string) string

ConfigPath determines the full path of a data file.

func (App) DataPath

func (a App) DataPath(file string) string

DataPath determines the full path of a data file.

func (App) SystemConfigPaths

func (a App) SystemConfigPaths(file string) []string

SystemConfigPaths determines system-wide possible paths for a config file.

func (App) SystemDataPaths

func (a App) SystemDataPaths(file string) []string

SystemDataPaths determines system-wide possible paths for a data file.

Jump to

Keyboard shortcuts

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