{"id":13693602,"url":"https://github.com/muesli/go-app-paths","last_synced_at":"2025-04-04T15:11:40.797Z","repository":{"id":28441672,"uuid":"118387716","full_name":"muesli/go-app-paths","owner":"muesli","description":"Lets you retrieve platform-specific paths (like directories for app-data, cache, config, and logs)","archived":false,"fork":false,"pushed_at":"2022-05-30T13:53:19.000Z","size":79,"stargazers_count":215,"open_issues_count":4,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-28T14:11:18.092Z","etag":null,"topics":["hacktoberfest"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/muesli.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"muesli"}},"created_at":"2018-01-22T00:47:20.000Z","updated_at":"2025-03-23T06:56:46.000Z","dependencies_parsed_at":"2022-08-26T11:10:46.845Z","dependency_job_id":null,"html_url":"https://github.com/muesli/go-app-paths","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muesli%2Fgo-app-paths","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muesli%2Fgo-app-paths/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muesli%2Fgo-app-paths/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muesli%2Fgo-app-paths/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/muesli","download_url":"https://codeload.github.com/muesli/go-app-paths/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247198469,"owners_count":20900081,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest"],"created_at":"2024-08-02T17:01:13.585Z","updated_at":"2025-04-04T15:11:40.773Z","avatar_url":"https://github.com/muesli.png","language":"Go","funding_links":["https://github.com/sponsors/muesli"],"categories":["开源类库","Open source library","Go"],"sub_categories":["文件/存储","Files/Storage"],"readme":"# go-app-paths\n\n[![Latest Release](https://img.shields.io/github/release/muesli/go-app-paths.svg)](https://github.com/muesli/go-app-paths/releases)\n[![GoDoc](https://godoc.org/github.com/golang/gddo?status.svg)](https://pkg.go.dev/github.com/muesli/go-app-paths?tab=doc)\n[![Build Status](https://github.com/muesli/go-app-paths/workflows/build/badge.svg)](https://github.com/muesli/go-app-paths/actions)\n[![Coverage Status](https://coveralls.io/repos/github/muesli/go-app-paths/badge.svg?branch=master)](https://coveralls.io/github/muesli/go-app-paths?branch=master)\n[![Go ReportCard](https://goreportcard.com/badge/muesli/go-app-paths)](https://goreportcard.com/report/muesli/go-app-paths)\n\nLets you retrieve platform-specific paths (like directories for app-data, cache,\nconfig, and logs). It is fully compliant with the [XDG Base Directory Specification](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html)\non Unix, but also provides implementations for macOS and Windows systems.\n\n## Installation\n\nMake sure you have a working Go environment (Go 1.2 or higher is required).\nSee the [install instructions](https://golang.org/doc/install.html).\n\nTo install go-app-paths, simply run:\n\n    go get github.com/muesli/go-app-paths\n\n## Usage\n\n```go\nimport gap \"github.com/muesli/go-app-paths\"\n```\n\n### Scopes\n\nYou can initialize `gap` with either the `gap.User` or `gap.System` scope to\nretrieve user- and/or system-specific base directories and paths:\n\n```go\nscope := gap.NewScope(gap.User, \"app\")\n```\n\nAlternatively, you can initialize `gap` with an additional vendor name:\n\n```go\nscope := gap.NewVendorScope(gap.User, \"vendor\", \"app\")\n```\n\nThis will cause the `app` directory to be prefixed by a `vendor` directory in\nall the following tables.\n\n### Directories\n\n`DataDirs` retrieves a priority-sorted list of data directories:\n\n```go\ndirs, err := scope.DataDirs()\n```\n\n| Platform | User Scope                                                       | System Scope                               |\n| -------- | ---------------------------------------------------------------- | ------------------------------------------ |\n| Unix     | [\"~/.local/share/app\", \"/usr/local/share/app\", \"/usr/share/app\"] | [\"/usr/local/share/app\", \"/usr/share/app\"] |\n| macOS    | [\"~/Library/Application Support/app\"]                            | [\"/Library/Application Support/app\"]       |\n| Windows  | [\"%LOCALAPPDATA%/app\"]                                           | [\"%PROGRAMDATA%/app\"]                      |\n\n---\n\n`ConfigDirs` retrieves a priority-sorted list of config directories:\n\n```go\ndirs, err := scope.ConfigDirs()\n```\n\n| Platform | User Scope                                    | System Scope                 |\n| -------- | --------------------------------------------- | ---------------------------- |\n| Unix     | [\"~/.config/app\", \"/etc/xdg/app\", \"/etc/app\"] | [\"/etc/xdg/app\", \"/etc/app\"] |\n| macOS    | [\"~/Library/Preferences/app\"]                 | [\"/Library/Preferences/app\"] |\n| Windows  | [\"%LOCALAPPDATA%/app/Config\"]                 | [\"%PROGRAMDATA%/app/Config\"] |\n\n---\n\n`CacheDir` retrieves the app's cache directory:\n\n```go\ndir, err := scope.CacheDir()\n```\n\n| Platform | User Scope               | System Scope            |\n| -------- | ------------------------ | ----------------------- |\n| Unix     | ~/.cache/app             | /var/cache/app          |\n| macOS    | ~/Library/Caches/app     | /Library/Caches/app     |\n| Windows  | %LOCALAPPDATA%/app/Cache | %PROGRAMDATA%/app/Cache |\n\n### Default File Paths\n\n`DataPath` retrieves the default path for a data file:\n\n```go\npath, err := scope.DataPath(\"filename\")\n```\n\n| Platform | User Scope                                 | System Scope                              |\n| -------- | ------------------------------------------ | ----------------------------------------- |\n| Unix     | ~/.local/share/app/filename                | /usr/local/share/app/filename             |\n| macOS    | ~/Library/Application Support/app/filename | /Library/Application Support/app/filename |\n| Windows  | %LOCALAPPDATA%/app/filename                | %PROGRAMDATA%/app/filename                |\n\n---\n\n`ConfigPath` retrieves the default path for a config file:\n\n```go\npath, err := scope.ConfigPath(\"filename.conf\")\n```\n\n| Platform | User Scope                              | System Scope                           |\n| -------- | --------------------------------------- | -------------------------------------- |\n| Unix     | ~/.config/app/filename.conf             | /etc/xdg/app/filename.conf             |\n| macOS    | ~/Library/Preferences/app/filename.conf | /Library/Preferences/app/filename.conf |\n| Windows  | %LOCALAPPDATA%/app/Config/filename.conf | %PROGRAMDATA%/app/Config/filename.conf |\n\n---\n\n`LogPath` retrieves the default path for a log file:\n\n```go\npath, err := scope.LogPath(\"filename.log\")\n```\n\n| Platform | User Scope                           | System Scope                        |\n| -------- | ------------------------------------ | ----------------------------------- |\n| Unix     | ~/.local/share/app/filename.log      | /var/log/app/filename.log           |\n| macOS    | ~/Library/Logs/app/filename.log      | /Library/Logs/app/filename.log      |\n| Windows  | %LOCALAPPDATA%/app/Logs/filename.log | %PROGRAMDATA%/app/Logs/filename.log |\n\n### Lookup Methods\n\n`LookupData` retrieves a priority-sorted list of paths for existing data files\nwith the name `filename`:\n\n```go\npath, err := scope.LookupData(\"filename\")\n```\n\n| Platform | User Scope                                                                                  | System Scope                                                 |\n| -------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------ |\n| Unix     | [\"~/.local/share/app/filename\", \"/usr/local/share/app/filename\", \"/usr/share/app/filename\"] | [\"/usr/local/share/app/filename\", \"/usr/share/app/filename\"] |\n| macOS    | [\"~/Library/Application Support/app/filename\"]                                              | [\"/Library/Application Support/app/filename\"]                |\n| Windows  | [\"%LOCALAPPDATA%/app/filename\"]                                                             | [\"%PROGRAMDATA%/app/filename\"]                               |\n\n---\n\n`LookupConfig` retrieves a priority-sorted list of paths for existing config\nfiles with the name `filename.conf`:\n\n```go\npath, err := scope.LookupConfig(\"filename.conf\")\n```\n\n| Platform | User Scope                                                                              | System Scope                                             |\n| -------- | --------------------------------------------------------------------------------------- | -------------------------------------------------------- |\n| Unix     | [\"~/.config/app/filename.conf\", \"/etc/xdg/app/filename.conf\", \"/etc/app/filename.conf\"] | [\"/etc/xdg/app/filename.conf\", \"/etc/app/filename.conf\"] |\n| macOS    | [\"~/Library/Preferences/app/filename.conf\"]                                             | [\"/Library/Preferences/app/filename.conf\"]               |\n| Windows  | [\"%LOCALAPPDATA%/app/Config/filename.conf\"]                                             | [\"%PROGRAMDATA%/app/Config/filename.conf\"]               |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmuesli%2Fgo-app-paths","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmuesli%2Fgo-app-paths","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmuesli%2Fgo-app-paths/lists"}