{"id":37188680,"url":"https://github.com/hop-/goconfig","last_synced_at":"2026-01-14T21:56:55.116Z","repository":{"id":57641769,"uuid":"246825095","full_name":"hop-/goconfig","owner":"hop-","description":"A Go port of Node.js config package (which uses json files to configure application)","archived":false,"fork":false,"pushed_at":"2024-07-01T22:07:01.000Z","size":18,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-08-08T09:59:17.227Z","etag":null,"topics":["config","configuration","environment","environment-variables","go","golang","json","json-configuration","node-config"],"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/hop-.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":"2020-03-12T12:10:43.000Z","updated_at":"2024-07-20T11:43:42.000Z","dependencies_parsed_at":"2022-09-26T17:11:31.167Z","dependency_job_id":null,"html_url":"https://github.com/hop-/goconfig","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/hop-/goconfig","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hop-%2Fgoconfig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hop-%2Fgoconfig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hop-%2Fgoconfig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hop-%2Fgoconfig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hop-","download_url":"https://codeload.github.com/hop-/goconfig/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hop-%2Fgoconfig/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28436249,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T21:32:52.117Z","status":"ssl_error","status_checked_at":"2026-01-14T21:32:33.442Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["config","configuration","environment","environment-variables","go","golang","json","json-configuration","node-config"],"created_at":"2026-01-14T21:56:54.291Z","updated_at":"2026-01-14T21:56:55.072Z","avatar_url":"https://github.com/hop-.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GoConfig\n\n![CI](https://github.com/hop-/goconfig/workflows/CI/badge.svg) [![Go Report Card](https://goreportcard.com/badge/github.com/hop-/goconfig)](https://goreportcard.com/report/github.com/hop-/goconfig)[![Go Reference](https://pkg.go.dev/badge/github.com/hop-/goconfig.svg)](https://pkg.go.dev/github.com/hop-/goconfig)\n\nA Go port of Node.js config package (which uses json files to configure application)\n\nFrom original Library:\n\u003e Library organizes hierarchical configurations for your app deployments.\n\u003e It lets you define a set of default parameters, and extend them for different deployment environments (development, qa, staging, production, etc.).\n\n## Installation\n\nAs a library\n\n```shell\ngo get github.com/hop-/goconfig\n```\n\nUsage:\n\nAll config files are in `HOST_CONFIG_DIR` directory, default is 'config'\n\nIt is using `HOST_ENV` environment variable to define the application deployment environment\n\n`$HOST_CONFIG_DIR`/default.json:\n\n```json\n{\n  \"Customer\": {\n    \"db\": {\n      \"host\": \"localhost\",\n      \"port\": 27017,\n      \"dbName\": \"customers\"\n    },\n    \"credit\": {\n      \"initialLimit\": 100,\n      \"initialDays\": 1\n    }\n  }\n}\n```\n\nOverride some configurations for production when `HOST_ENV` is 'production'.\n\n`$HOST_CONFIG_DIR`/production.json:\n\n```json\n{\n  \"Customer\": {\n    \"credit\": {\n      \"initialDays\": 30\n    }\n  }\n}\n```\n\nUse config in your code:\n\n```go\nimport \"github.com/hop-/goconfig\"\n\ntype Consumer struct {\n  Consumer struct {\n    Db struct {\n      host string\n      port int\n      dbName string\n    }\n    Credit struct {\n      InitialLimit int\n      InitialDays int\n    }\n  }\n}\n\nfunc main() {\n  if err := goconfig.Load(); err != nil {\n    // Some error handling\n  }\n\n  consumer, err := goconfig.Get[Consumer](\"Consumer\")\n  if err != nil {\n    // Some error handling\n  }\n\n  host, err := goconfig.Get[string](\"Consumer.Db.host\")\n  if err != nil {\n    // Some error handling\n  }\n\n  // Your code\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhop-%2Fgoconfig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhop-%2Fgoconfig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhop-%2Fgoconfig/lists"}