A cross platform package that follows the XDG Standard

XDG Build status Build Status Go Report Card GoDoc codecov

A cross platform package that tries to follow XDG Standard when possible. Since XDG is linux specific, I am only able to follow standards to the T on linux. But for the other operating systems I am finding similar best practice locations for the files.

Locations Per OS

The following table shows what is used if the envrionment variable is not set. If the variable is set then this package uses that. Linux follows the default standards. Mac does when it comes to the home directory but for system wide it uses the standard /Library/Application Support. As for Windows, the variable defaults are just other environment variables set up by the operation system.

When creating XDG application the Vendor and Application names are appeneded to the end of the path to keep projects unique.

Linux(and BSD) Mac Windows
XDG_DATA_DIRS [/usr/local/share, /usr/share] [/Library/Application Support] %PROGRAMDATA%
XDG_DATA_HOME ~/.local/share ~/Library/Application Support %APPDATA%
XDG_CONFIG_DIRS [/etc/xdg] [/Library/Application Support] %PROGRAMDATA%
XDG_CONFIG_HOME ~/.config ~/Library/Application Support %APPDATA%
XDG_CACHE_HOME ~/.cache ~/Library/Caches %LOCALAPPDATA%

Notes

  • This package does not merge files if they exist across different directories.
  • The Query methods search through the system variables, DIRS, first (when using environment variables first in the variable has presidence). It then checks home variables, HOME.
  • This package will not create any directories for you. In the standard, it states the following:

If, when attempting to write a file, the destination directory is non-existant an attempt should be made to create it with permission 0700. If the destination directory exists already the permissions should not be changed. The application should be prepared to handle the case where the file could not be written, either because the directory was non-existant and could not be created, or for any other reason. In such case it may chose to present an error message to the user.

Comments
  • Better Mac settings

    Better Mac settings

    From https://stackoverflow.com/a/5084892

    • XDG_DATA_DIRS: /Library
    • XDG_DATA_HOME: ~/Library
    • XDG_CONFIG_DIRS: /Library/Preferences
    • XDG_CONFIG_HOME: ~/Library/Preferences
    • XDG_CACHE_DIRS: /Library/Caches
    • XDG_CACHE_HOME: ~/Library/Caches

    I use these personally on my Mac and it works very well with the ecosystem.

  • Update link to XDG spec

    Update link to XDG spec

    In a ham-fisted move of apparent humility, freedesktop.org has apparently taken a step back from asserting their recommendations as standards by breaking their URLs (s/standards/specifications) without the courtesy of providing the appropriate HTTP redirects which are, ironically, universally recognized as standard.

    Update broken link.

  • Modify Mac Defaults and Change Query Order

    Modify Mac Defaults and Change Query Order

    I am also adding support for go modules so that users can use v0.1.0 before these changes and still get the same functionality as some of these changes are breaking. But since I never made a v1 release I think this is fine.

    Fixes #1 Fixes #2

  •  Add poweron architecture ppc64le to travis build

    Add poweron architecture ppc64le to travis build

    This is part of the Ubuntu distribution for ppc64le. This helps us simplify testing later when distributions are re-building and re-releasing,For more info tag @gerrith3.

  • Create new tag with BSD suppport

    Create new tag with BSD suppport

    Hey, thanks for this library! I just tested your changes adding BSD support on OpenBSD via the slack-term application that I was trying to setup. It seems to be working fine, could you tag a new version that includes the new commits? Then I can submit a PR to the slack-term project to bump their go.mod

    Thanks again!

  • Looking into non-home dir before global dir does not make sense?

    Looking into non-home dir before global dir does not make sense?

    Hi,

    I noticed that QueryData and QueryConfig get their "home" dir appended to the end. This I think is incorrect. I think it should first look if the env var is set and look in there, then in the default home dir fallowed by the rest of of the dirs.

    Or am I wrong? (I did read the spec at https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html)

  • Support more XDG directories

    Support more XDG directories

    Please also support those directories:

    • USER_DIRECTORY_DESKTOP
    • USER_DIRECTORY_DOCUMENTS
    • USER_DIRECTORY_DOWNLOAD
    • USER_DIRECTORY_MUSIC
    • USER_DIRECTORY_PICTURES
    • USER_DIRECTORY_PUBLIC_SHARE
    • USER_DIRECTORY_TEMPLATES
    • USER_DIRECTORY_VIDEOS
    • USER_N_DIRECTORIES
A lightweight yet powerful config package for Go projects

Config GoLobby Config is a lightweight yet powerful config package for Go projects. It takes advantage of env files and OS variables alongside config

Dec 11, 2022
Configure is a Go package that gives you easy configuration of your project through redundancy

Configure Configure is a Go package that gives you easy configuration of your project through redundancy. It has an API inspired by negroni and the fl

Sep 26, 2022
Go package that interfaces with AWS System Manager

go-aws-ssm Go package that interfaces with AWS System Manager. Why to use go-aws-ssm and not the aws-sdk-go? This package is wrapping the aws-sdk-go a

Nov 12, 2022
Package ini provides INI file read and write functionality in Go.

INI Package ini provides INI file read and write functionality in Go. Features Load from multiple data sources(file, []byte, io.Reader and io.ReadClos

Dec 29, 2022
A golang package for parsing ini-style configuration files

Mini Mini is a simple ini configuration file parser. The ini syntax supported includes: The standard name=value Comments on new lines starting with #

Jan 7, 2023
Flags-first package for configuration

ff stands for flags-first, and provides an opinionated way to populate a flag.FlagSet with configuration data from the environment.

Dec 26, 2022
Environment variables configuration package for Go microservices.

gocfg Environment variables configuration package for Go microservices. It helps validate environment variable values and set default values if needed

Dec 30, 2021
SmartYAML - Go package to handle YAML

SmartYAML - Go package to handle YAML The smartyaml is a go package to handle parsed YAML files more confortable. This package is not a parser, it use

Feb 25, 2022
Yet another config package

cfg Yet another config package Features Read from file Read from environment variable Hot reload of the file Usage package main import ( "context"

Jan 16, 2022
Lightweight package that makes easier and safer to deal with environment variables.

Envisage A lightweight package that makes easier and safer to deal with environment variables. Example Try it on On GoPlay https://goplay.tools/snippe

Apr 11, 2022
Go implementation of the XDG Base Directory Specification and XDG user directories

xdg Provides an implementation of the XDG Base Directory Specification. The specification defines a set of standard paths for storing application file

Jan 5, 2023
Go implementation of the XDG Base Directory Specification and XDG user directories

xdg Provides an implementation of the XDG Base Directory Specification. The specification defines a set of standard paths for storing application file

Dec 23, 2022
sail is an operation framework based on Ansible/Helm. sail follows the principles of Infrastructure as Code (IaC), Operation as Code (OaC), and Everything as Code. So it is a tool for DevOps.

sail 中文文档 sail is an operation framework based on Ansible/Helm. sail follows the principles of Infrastructure as Code (IaC), Operation as Code (OaC),a

Dec 16, 2021
LeetCode in Go with the code style strictly follows the Google Golang Style Guide
LeetCode in Go with the code style strictly follows the Google Golang Style Guide

LeetCode in Go LeetCode Online Judge is a website containing many algorithm questions. Most of them are real interview questions of Google, Facebook,

Nov 13, 2021
Powerful and versatile MIME sniffing package using pre-compiled glob patterns, magic number signatures, XML document namespaces, and tree magic for mounted volumes, generated from the XDG shared-mime-info database.

mimemagic Powerful and versatile MIME sniffing package using pre-compiled glob patterns, magic number signatures, xml document namespaces, and tree ma

Nov 3, 2022
FreeDesktop.org (xdg) Specs implemented in Go

xdg Package xdg provides access to the FreeDesktop.org (XDG) specs. Documentation Documentation is available via godoc. Here are direct links to the d

Nov 11, 2022
A wrapper around cd and xdg-open to use aliases to directory paths in terminal

CDD - Change directories Dynamically I am a lazy linux user and turns out that basic tab completion wasn't enough for me to navigate through my direct

Dec 15, 2022
A Go (golang) package that enhances the standard database/sql package by providing powerful data retrieval methods as well as DB-agnostic query building capabilities.

ozzo-dbx Summary Description Requirements Installation Supported Databases Getting Started Connecting to Database Executing Queries Binding Parameters

Dec 31, 2022
📋 cross-platform clipboard package that supports accessing text and image in Go (macOS/Linux/Windows/Android/iOS)

clipboard Cross platform (macOS/Linux/Windows/Android/iOS) clipboard package in Go import "golang.design/x/clipboard" Features Cross platform supports

Dec 24, 2022
GoFish is a cross-platform systems package manager, bringing the ease of use of Homebrew to Linux and Windows.

GoFish is a cross-platform systems package manager, bringing the ease of use of Homebrew to Linux and Windows.

Dec 11, 2022