go-app-paths lets you retrieve platform-specific paths (like app-data, cache, config and logs)

综合技术 Github (源链)

go-app-paths

Lets you retrieve platform-specific paths (like directories for app-data, cache, config, and logs)

Installation

Make sure you have a working Go environment (Go 1.2 or higher is required). See the install instructions .

To install go-app-paths, simply run:

go get github.com/muesli/go-app-paths

To compile it from source:

cd $GOPATH/src/github.com/muesli/go-app-paths
go get -u -v
go build && go test -v

Platform Support

UnixUser ScopeSystem Scope
Data Dir${XDG_DATA_HOME}/appname/usr/share/appname
Cache Dir${XDG_CACHE_HOME}/appname/var/cache/appname
Config Path${XDG_CONFIG_HOME}/appname/filename/etc/appname/filename
Log Path${XDG_DATA_HOME}/appname/filename/var/log/appname/filename
macOSUser ScopeSystem Scope
Data Dir~/Library/Application Support/appname/Library/Application Support/appname
Cache Dir~/Library/Caches/appname/Library/Caches/appname
Config Path~/Library/Preferences/appname/filename/Library/Preferences/appname/filename
Log Path~/Library/Logs/appname/filename/Library/Logs/appname/filename
WindowsUser ScopeSystem Scope
Data Dir%LOCALAPPDATA%/appname%PROGRAMDATA%/appname
Cache Dir%LOCALAPPDATA%/appname/Cache%PROGRAMDATA%/appname/Cache
Config Path%LOCALAPPDATA%/appname/Config/filename%PROGRAMDATA%/appname/Config/filename
Log Path%LOCALAPPDATA%/appname/Logs/filename%PROGRAMDATA%/appname/Logs/filename

Example

package main

import (
	"github.com/muesli/go-app-paths"
)

func main() {
	userScope := apppaths.NewScope(apppaths.User, "vendorname", "appname")
	userScope.DataDir()                   // => ~/.local/share/appname
	userScope.CacheDir()                  // => ~/.cache/appname
	userScope.ConfigPath("filename.conf") // => ~/.config/appname/filename.conf
	userScope.LogPath("filename.log")     // => ~/.local/share/appname/filename.log

	systemScope := apppaths.NewScope(apppaths.System, "vendorname", "appname")
	systemScope.DataDir()                   // => /usr/share/appname
	systemScope.CacheDir()                  // => /var/cache/appname
	systemScope.ConfigPath("filename.conf") // => /etc/appname/filename.conf
	systemScope.LogPath("filename.log")     // => /var/log/appname/filename.log
}

Development

API docs can be found here .

https://travis-ci.org/muesli/go-app-paths https://coveralls.io/github/muesli/go-app-paths?branch=master

您可能感兴趣的

Nymph – A slightly different version of C Nymph Let's see what we can achieve by reworking C syntax. Overview Nymph is a simple C like programming language. This repository contains...
nscd.conf nscd是啥就不用介绍了,能找到这里的说明已经知道自己的需求了。nscd程序在启动的时候会读取/etc/nscd.conf文件, 每一行指定一个属性和对应的值,或者指定一个服务和对应的值,#表示注释 有效的服务设定是:passwd, group, hosts, services, or ne...
Introducing DifferentialEquations.jl Differential equations are ubiquitous throughout mathematics and the sciences. In fact, I myself have studied various forms of differential equations ...
Jaeger – A Distributed Tracing System https://travis-ci.org/jaegertracing/jaeger https://coveralls.io/github/jaegertracing/jaeger?branch=master https://godoc.org/github.com/uber/jaeger ht...
Reading text file and split by line There are many troublesome in text processing in the programming language C. Even just write program that read line by line make time consume. I have...
Github责编内容来自:Github (源链) | 更多关于

阅读提示:酷辣虫无法对本内容的真实性提供任何保证,请自行验证并承担相关的风险与后果!
本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。
酷辣虫 » go-app-paths lets you retrieve platform-specific paths (like app-data, cache, config and logs)



专业 x 专注 x 聚合 x 分享 CC BY-NC-SA 4.0

使用声明 | 英豪名录