{"id":18073371,"url":"https://github.com/blakewilliams/go-xdg","last_synced_at":"2026-02-03T04:03:29.879Z","repository":{"id":258268283,"uuid":"871687004","full_name":"BlakeWilliams/go-xdg","owner":"BlakeWilliams","description":"Tools for working with XDG directories in Go","archived":false,"fork":false,"pushed_at":"2024-10-13T16:26:29.000Z","size":8,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-15T14:57:11.009Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/BlakeWilliams.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-12T16:53:33.000Z","updated_at":"2024-11-23T21:02:25.000Z","dependencies_parsed_at":"2024-10-18T08:14:53.326Z","dependency_job_id":null,"html_url":"https://github.com/BlakeWilliams/go-xdg","commit_stats":null,"previous_names":["blakewilliams/go-xdg"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlakeWilliams%2Fgo-xdg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlakeWilliams%2Fgo-xdg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlakeWilliams%2Fgo-xdg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlakeWilliams%2Fgo-xdg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BlakeWilliams","download_url":"https://codeload.github.com/BlakeWilliams/go-xdg/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230359932,"owners_count":18214157,"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":[],"created_at":"2024-10-31T10:06:37.130Z","updated_at":"2026-02-03T04:03:29.812Z","avatar_url":"https://github.com/BlakeWilliams.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-XDG\n\nThis package implements (a subset of) the XDG Base Directory Specification in\nGo. It uses the user expected directories as defined by the XDG Base Directory\nSpecification for Linux/Unix/macOS and (soon) Windows.\n\n\n### Linux/macOS directories\n\n- Config - `$XDG_CONFIG_HOME` or `$HOME/.config`\n- Data - `$XDG_DATA_HOME` or `$HOME/.local/share`\n- Cache - `$XDG_CACHE_HOME` or `$HOME/.cache`\n- State - `$XDG_STATE_HOME` or `$HOME/.local/state`\n\n### Windows directories\n\n**Windows support has not been tested yet**. Assistance/contributions very welcome here.\n\nFirst, it checks the following environment variables if the `XDG_*_HOME`\nvariable is not set:\n\n- Config - `%APPDATA%`\n- Data - `%APPDATA%`\n- Cache - `%LOCALAPPDATA%`\n- State - `%LOCALAPPDATA%`\n\nIf the environment variables are not set, it falls back to the following:\n\n- Config - `%USERPROFILE%\\AppData\\Local`\n- Data - `%USERPROFILE%\\AppData\\Local`\n- Cache - `%USERPROFILE%\\AppData\\Local\\Temp`\n- State - `%USERPROFILE%\\AppData\\Local`\n\n## Installation\n\n```sh\ngo get github.com/blakewilliams/go-xdg\n```\n\n## Usage\n\nThe API is relatively simple. Each directory has a function that returns the\npath to the directory or an error (e.g. if $HOME is not set in macOS/Linux).\n\n```go\nimport \"github.com/blakewilliams/go-xdg\"\n\n// Get the config directory\nconfigDir, err := xdg.ConfigHome()\n\n// Get the data directory\ndataDir, err := xdg.DataHome()\n\n// Get the cache directory\ncacheDir, err := xdg.CacheHome()\n\n// Get the state directory\nstateDir, err := xdg.StateHome()\n```\n\nThis package also has support for finding files. It will return the path to the\nfile if it is found, otherwise it returns an `ErrNoFile` error.\n\n```go\nimport \"github.com/blakewilliams/go-xdg\"\n\n// Find `myapp/config.yaml` in the config directory\nconfigFilePath, err := xdg.FindConfigFile(\"myapp\", \"config.yaml\")\n\n// Find `myapp/data.json` in the data directory\ndataFilePath, err := xdg.FindDataFile(\"myapp\", \"data.json\")\n\n// Find `myapp/cache.db` in the cache directory\ndataFilePath, err := xdg.FindCacheFile(\"myapp\", \"cache.db\")\n\n// Find `myapp/state.db` in the state directory\nstateFilePath, err := xdg.FindStateFile(\"myapp\", \"state.db\")\n```\n\n## Contributions welcome!\n\nIf you'd like to contribute, please create an issue with a proposal for your\nchange before opening a PR if you'd like to ensure it will be accepted.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblakewilliams%2Fgo-xdg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblakewilliams%2Fgo-xdg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblakewilliams%2Fgo-xdg/lists"}