{"id":42669051,"url":"https://github.com/mdm-code/xdg","last_synced_at":"2026-01-29T10:22:35.508Z","repository":{"id":57656183,"uuid":"454751195","full_name":"mdm-code/xdg","owner":"mdm-code","description":"File discovery based on XDG Base Directory Specification for Go.","archived":false,"fork":false,"pushed_at":"2024-01-25T20:48:13.000Z","size":233,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-01-25T21:41:29.042Z","etag":null,"topics":["go","golang","golang-package","unix","xdg","xdg-basedir","xdg-compliance"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/mdm-code/xdg","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/mdm-code.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-02-02T11:39:48.000Z","updated_at":"2023-09-26T12:03:36.000Z","dependencies_parsed_at":"2024-01-25T21:48:05.667Z","dependency_job_id":null,"html_url":"https://github.com/mdm-code/xdg","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/mdm-code/xdg","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdm-code%2Fxdg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdm-code%2Fxdg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdm-code%2Fxdg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdm-code%2Fxdg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mdm-code","download_url":"https://codeload.github.com/mdm-code/xdg/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdm-code%2Fxdg/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28875450,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-29T09:47:23.353Z","status":"ssl_error","status_checked_at":"2026-01-29T09:47:19.357Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["go","golang","golang-package","unix","xdg","xdg-basedir","xdg-compliance"],"created_at":"2026-01-29T10:22:34.506Z","updated_at":"2026-01-29T10:22:35.501Z","avatar_url":"https://github.com/mdm-code.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n  \u003cdiv\u003e\n    \u003cimg src=\"https://raw.githubusercontent.com/mdm-code/mdm-code.github.io/main/xdg_logo.png\" alt=\"logo\"/\u003e\n  \u003c/div\u003e\n\u003c/h1\u003e\n\n\u003ch4 align=\"center\"\u003eThe XDG Base Directory Specification implemented in Go.\u003c/h4\u003e\n\n\u003cdiv align=\"center\"\u003e\n\u003cp\u003e\n    \u003ca href=\"https://github.com/mdm-code/xdg/actions?query=workflow%3ACI\"\u003e\n        \u003cimg alt=\"Build status\" src=\"https://github.com/mdm-code/xdg/workflows/CI/badge.svg\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://app.codecov.io/gh/mdm-code/xdg\"\u003e\n        \u003cimg alt=\"Code coverage\" src=\"https://codecov.io/gh/mdm-code/xdg/branch/main/graphs/badge.svg?branch=main\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://opensource.org/licenses/MIT\" rel=\"nofollow\"\u003e\n        \u003cimg alt=\"MIT license\" src=\"https://img.shields.io/github/license/mdm-code/xdg\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://goreportcard.com/report/github.com/mdm-code/xdg\"\u003e\n        \u003cimg alt=\"Go report card\" src=\"https://goreportcard.com/badge/github.com/mdm-code/xdg\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://pkg.go.dev/github.com/mdm-code/xdg\"\u003e\n        \u003cimg alt=\"Go package docs\" src=\"https://img.shields.io/badge/go.dev-reference-007d9c?logo=go\u0026logoColor=white\"\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\u003c/div\u003e\n\nThe [XDG Base Directory Specification](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html\n)  allows you specify directories where\nruntime files, configurations, data and caches are kept. The file discovery\nprocess is automatic and adheres to the XDG standard.\n\nThis package supports most Unix-based operating systems. It should work fine on\nMacOS. I wrote this package for my personal needs: to deduplicate this kind of\nfunctionality from my other programs, but it is very much a self-contained\nimplementation.\n\nSee [Usage](#usage) section below for examples. Package documentation is\navailable here: https://pkg.go.dev/github.com/mdm-code/xdg.\n\n\n## Installation\n\n```sh\ngo get github.com/mdm-code/xdg\n```\n\n\n## Default locations\n\nThe table shows default values for XDG environmental variables for Unix-like systems:\n\n| \u003ca href=\"#default-locations\"\u003e\u003cimg width=\"1000\" height=\"0\"\u003e\u003c/a\u003e | \u003ca href=\"#default-locations\"\u003e\u003cimg width=\"1000\" height=\"0\"\u003e\u003c/a\u003e\u003cp\u003eUnix-like\u003c/p\u003e |\n| :------------------------------------------------------------: | :----------------------------------------------------------------------------: |\n| \u003ckbd\u003e\u003cb\u003eXDG_DATA_HOME\u003c/b\u003e\u003c/kbd\u003e                                | \u003ckbd\u003e$HOME/.local/share\u003c/kbd\u003e                                                  |\n| \u003ckbd\u003e\u003cb\u003eXDG_CONFIG_HOME\u003c/b\u003e\u003c/kbd\u003e                              | \u003ckbd\u003e$HOME/.config\u003c/kbd\u003e                                                       |\n| \u003ckbd\u003e\u003cb\u003eXDG_STATE_HOME\u003c/b\u003e\u003c/kbd\u003e                               | \u003ckbd\u003e$HOME/.local/state\u003c/kbd\u003e                                                  |\n| \u003ckbd\u003e\u003cb\u003eXDG_DATA_DIRS\u003c/b\u003e\u003c/kbd\u003e                                | \u003ckbd\u003e/usr/local/share/:/usr/share/\u003c/kbd\u003e                                       |\n| \u003ckbd\u003e\u003cb\u003eXDG_CONFIG_DIRS\u003c/b\u003e\u003c/kbd\u003e                              | \u003ckbd\u003e/etc/xdg\u003c/kbd\u003e                                                            |\n| \u003ckbd\u003e\u003cb\u003eXDG_CACHE_HOME\u003c/b\u003e\u003c/kbd\u003e                               | \u003ckbd\u003e$HOME/.cache\u003c/kbd\u003e                                                        |\n| \u003ckbd\u003e\u003cb\u003eXDG_RUNTIME_DIR\u003c/b\u003e\u003c/kbd\u003e                              | \u003ckbd\u003e$TMPDIR\u003c/kbd\u003e                                                             |\n\n\n## Usage\n\nHere is an example of how to use the public API of the `xdg` package.\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/mdm-code/xdg\"\n)\n\nfunc main() {\n\t// XDG base directory paths.\n\tdirs := []struct {\n\t\tmsg string\n\t\tpth string\n\t}{\n\t\t{\"Home data directory: \", xdg.DataHomeDir()},\n\t\t{\"Config home directory: \", xdg.CacheHomeDir()},\n\t\t{\"State home directory: \", xdg.StateHomeDir()},\n\t\t{\"Data directories: \", xdg.DataDirs()},\n\t\t{\"Config directories: \", xdg.ConfigDirs()},\n\t\t{\"Cache home directory: \", xdg.CacheHomeDir()},\n\t\t{\"Runtime home directory: \", xdg.RuntimeDir()},\n\t}\n\tfor _, d := range dirs {\n\t\tfmt.Println(d.msg, d.pth)\n\t}\n\n\t// Search for file in data XDG directories.\n\tfpath := \"/prog/file\"\n\tif f, ok := xdg.Find(xdg.Data, fpath); ok {\n\t\tfmt.Println(f)\n\t} else {\n\t\tfmt.Printf(\"ERROR: couldn't find %s\\n\", fpath)\n\t}\n}\n```\n\n\n## Development\n\nConsult [Makefile](Makefile) to see how to format, examine code with `go vet`,\nrun unit test, run code linter with `golint` get test coverage and check if the\npackage builds all right.\n\nRemember to install `golint` before you try to run tests and test the build:\n\n```sh\ngo install golang.org/x/lint/golint@latest\n```\n\n\n## License\n\nCopyright (c) 2023 Michał Adamczyk.\n\nThis project is licensed under the [MIT license](https://opensource.org/licenses/MIT).\nSee [LICENSE](LICENSE) for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmdm-code%2Fxdg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmdm-code%2Fxdg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmdm-code%2Fxdg/lists"}