Socket
Book a DemoInstallSign in
Socket

xiam.li/appdirs

Package Overview
Dependencies
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xiam.li/appdirs

Go Modules
Version
v0.1.0
Version published
Created
Source

go-appdirs

GoDoc

Go package to get application directories such as config and cache.

PlatformLinux/BSDsmacOSWindows
User-specific data$XDG_DATA_HOME OR $HOME/.local/share$HOME/Library/Application SupportUnsupported
User-specific config$XDG_CONFIG_HOME OR $HOME/.config$HOME/Library/Application SupportUnsupported
User-specific cache$XDG_CACHE_HOME OR $HOME/.cache$HOME/Library/CachesUnsupported
User-specific logs$XDG_CACHE_HOME OR $HOME/.cache$HOME/Library/LogsUnsupported
Shared data$XDG_DATA_DIRS OR /usr/local/share/Library/Application SupportUnsupported
Shared config$XDG_CONFIG_DIRS OR /etc/xdg/Library/Application SupportUnsupported
Shared cache/tmp/$(APP)-cache/Library/CachesUnsupported
Shared logs$(SHARED_DATA)/logs/Library/LogsUnsupported

Forked from emersion, which got forked from ProtonMail's implemention, which was inspired by configdir.

Usage

package main

import (
	"os"
	"path/filepath"

	"xiam.li/appdirs"
)

func main() {
	// Get directories for our app
	dirs := appdir.New("my-awesome-app")

	// Get user-specific config dir
	p := dirs.UserConfig()

	// Create our app config dir
	if err := os.MkdirAll(p, 0755); err != nil {
		panic(err)
	}

	// Now we can use it
	f, err := os.Create(filepath.Join(p, "config-file"))
	if err != nil {
		panic(err)
	}
	defer f.Close()

	f.Write([]byte("<3"))
}

License

MIT

FAQs

Package last updated on 13 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts