{"id":13707057,"url":"https://github.com/kirsle/configdir","last_synced_at":"2026-02-03T09:04:49.470Z","repository":{"id":57493836,"uuid":"80269549","full_name":"kirsle/configdir","owner":"kirsle","description":"A cross-platform Go library to get configuration and cache directories.","archived":false,"fork":false,"pushed_at":"2017-01-28T06:04:43.000Z","size":8,"stargazers_count":76,"open_issues_count":0,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-13T15:49:25.538Z","etag":null,"topics":["configdir","go","golang","xdg","xdg-basedir"],"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/kirsle.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}},"created_at":"2017-01-28T06:04:27.000Z","updated_at":"2024-10-13T12:11:08.000Z","dependencies_parsed_at":"2022-09-04T15:40:12.461Z","dependency_job_id":null,"html_url":"https://github.com/kirsle/configdir","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kirsle%2Fconfigdir","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kirsle%2Fconfigdir/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kirsle%2Fconfigdir/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kirsle%2Fconfigdir/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kirsle","download_url":"https://codeload.github.com/kirsle/configdir/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252593270,"owners_count":21773437,"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":["configdir","go","golang","xdg","xdg-basedir"],"created_at":"2024-08-02T22:01:16.983Z","updated_at":"2026-02-03T09:04:44.438Z","avatar_url":"https://github.com/kirsle.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# ConfigDir for Go\n\nThis library provides a cross platform means of detecting the system's\nconfiguration directories so that your Go app can store config files in a\nstandard location. For Linux and other Unixes (BSD, etc.) this means using the\n[Freedesktop.org XDG Base Directory Specification][1] (0.8), and for Windows\nand macOS it uses their standard directories.\n\nThis is a simple no-nonsense module that just gives you the path names to do\nwith as you please. You can either get the bare root config path, or get a\npath with any number of names suffixed onto it for vendor- or\napplication-specific namespacing.\n\nFor the impatient, the directories this library can return tend to be like\nthe following:\n\n|         | **System-wide Configuration**                       |\n|---------|-----------------------------------------------------|\n| Windows | `%PROGRAMDATA%` or `C:\\ProgramData`                 |\n| Linux   | `$XDG_CONFIG_DIRS` or `/etc/xdg`                    |\n| macOS   | `/Library/Application Support`                      |\n|         | **User-level Configuration**                        |\n| Windows | `%APPDATA%` or `C:\\Users\\%USER%\\AppData\\Roaming`    |\n| Linux   | `$XDG_CONFIG_HOME` or `$HOME/.config`               |\n| macOS   | `$HOME/Library/Application Support`                 |\n|         | **User-level Cache Folder**                         |\n| Windows | `%LOCALAPPDATA%` or `C:\\Users\\%USER%\\AppData\\Local` |\n| Linux   | `$XDG_CACHE_HOME` or `$HOME/.cache`                 |\n| macOS   | `$HOME/Library/Caches`                              |\n\n## Quick Start\n\n```go\n// A common use case is to get a private config folder for your app to\n// place its settings files into, that are specific to the local user.\nconfigPath := configdir.LocalConfig(\"my-app\")\nerr := configdir.MakePath(configPath) // Ensure it exists.\nif err != nil {\n    panic(err)\n}\n\n// Deal with a JSON configuration file in that folder.\nconfigFile := filepath.Join(configPath, \"settings.json\")\ntype AppSettings struct {\n    Username string `json:\"username\"`\n    Password string `json:\"password\"`\n}\nvar settings AppSettings\n\n// Does the file not exist?\nif _, err = os.Stat(configFile); os.IsNotExist(err) {\n    // Create the new config file.\n    settings = AppSettings{\"MyUser\", \"MyPassword\"}\n    fh, err := os.Create(configFile)\n    if err != nil {\n        panic(err)\n    }\n    defer fh.Close()\n\n    encoder := json.NewEncoder(fh)\n    encoder.Encode(\u0026settings)\n} else {\n    // Load the existing file.\n    fh, err := os.Open(configFile)\n    if err != nil {\n        panic(err)\n    }\n    defer fh.Close()\n\n    decoder := json.NewDecoder(fh)\n    decoder.Decode(\u0026settings)\n}\n```\n\n## Documentation\n\nPackage documentation is available at\n\u003chttps://godoc.org/github.com/kirsle/configdir\u003e\n\n## Author\n\nNoah Petherbridge, [@kirsle](https://github.com/kirsle)\n\n## License\n\nMIT\n\n[1]: https://specifications.freedesktop.org/basedir-spec/basedir-spec-0.8.html\n[2]: https://github.com/shibukawa/configdir\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkirsle%2Fconfigdir","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkirsle%2Fconfigdir","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkirsle%2Fconfigdir/lists"}