{"id":16138487,"url":"https://github.com/hashimthearab/gocon","last_synced_at":"2025-04-06T17:26:09.717Z","repository":{"id":211057660,"uuid":"728062318","full_name":"HashimTheArab/gocon","owner":"HashimTheArab","description":"The simplest settings and config library for your Go app.","archived":false,"fork":false,"pushed_at":"2023-12-06T17:49:37.000Z","size":17,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-12T23:34:31.994Z","etag":null,"topics":["config","go","golang","settings"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HashimTheArab.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":"2023-12-06T06:31:36.000Z","updated_at":"2023-12-07T16:56:45.000Z","dependencies_parsed_at":"2023-12-06T09:20:12.388Z","dependency_job_id":"7c6a68b8-7aee-4c70-b692-36ee10453fbd","html_url":"https://github.com/HashimTheArab/gocon","commit_stats":null,"previous_names":["hashimthearab/gocon"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HashimTheArab%2Fgocon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HashimTheArab%2Fgocon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HashimTheArab%2Fgocon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HashimTheArab%2Fgocon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HashimTheArab","download_url":"https://codeload.github.com/HashimTheArab/gocon/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247519938,"owners_count":20952082,"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":["config","go","golang","settings"],"created_at":"2024-10-09T23:34:24.597Z","updated_at":"2025-04-06T17:26:09.669Z","avatar_url":"https://github.com/HashimTheArab.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GoCon\nGoCon is the simplest way to store and load a config in your Go program.\n\n## Installation\n\nTo use GoCon in your Go project, you can install it by using `go get`:\n\n```bash\ngo get github.com/HashimTheArab/gocon\n```\n\n## Example\n\n```go\ntype Settings struct {\n    Theme string\n    DarkMode bool\n}\n\nfunc (Settings) Path() string {\n    return \"settings.json\"\n}\n\nfunc main(){\n    // Load the settings\n    settings, err := gocon.Load[Settings]()\n    if err != nil {\n        // If the file fails to load, or it was not found, an error will be returned.\n        panic(err)\n    }\n\n    // Save settings\n    gocon.Save(Settings{Theme: \"blue\", DarkMode: true})\n}\n```\n\n## Explanation\n\nDefine a config struct, you can define multiple and each one will be saved to a separate file.\n\n1. **Define Your Settings Struct:**\u003cbr\u003e\nIn your settings.go file, define a struct representing your application settings. Implement the Path method to specify the path where the configuration file will be stored.\n```go\ntype Settings struct {\n    Theme string\n    DarkMode bool\n}\n\nfunc (Settings) Path() string {\n    return \"settings.json\"\n}\n```\n\n2. **Load and save settings:**\u003cbr\u003e\nAfter creating your settings struct, you can simply use it. \n\nYou can save a config:\n```go\ngocon.Save(Settings{Theme: \"blue\", DarkMode: true})\n```\n\nAnd then you can load it in the future:\n```go\nsettings, _ := gocon.Load[Settings]()\n```\n\nYou can have multiple configs / settings, each struct will be saved to its own path.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhashimthearab%2Fgocon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhashimthearab%2Fgocon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhashimthearab%2Fgocon/lists"}