{"id":23122854,"url":"https://github.com/wissance/go-config-extender","last_synced_at":"2026-01-28T21:02:29.653Z","repository":{"id":265541882,"uuid":"896082569","full_name":"Wissance/go-config-extender","owner":"Wissance","description":"A Package to override config  with environment variables","archived":false,"fork":false,"pushed_at":"2024-11-30T20:42:50.000Z","size":15,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-07T05:04:23.733Z","etag":null,"topics":["configuration-management","docker-configuration","go-configuration","go-docker"],"latest_commit_sha":null,"homepage":"https://wissance.github.io/go-config-extender/","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Wissance.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,"zenodo":null}},"created_at":"2024-11-29T14:05:38.000Z","updated_at":"2024-12-13T11:20:14.000Z","dependencies_parsed_at":"2025-05-07T05:14:16.855Z","dependency_job_id":null,"html_url":"https://github.com/Wissance/go-config-extender","commit_stats":null,"previous_names":["wissance/go-config-extender"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Wissance/go-config-extender","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wissance%2Fgo-config-extender","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wissance%2Fgo-config-extender/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wissance%2Fgo-config-extender/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wissance%2Fgo-config-extender/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Wissance","download_url":"https://codeload.github.com/Wissance/go-config-extender/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wissance%2Fgo-config-extender/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28851838,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-28T15:15:36.453Z","status":"ssl_error","status_checked_at":"2026-01-28T15:15:13.020Z","response_time":57,"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":["configuration-management","docker-configuration","go-configuration","go-docker"],"created_at":"2024-12-17T07:31:04.103Z","updated_at":"2026-01-28T21:02:29.648Z","avatar_url":"https://github.com/Wissance.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## 1. DESCRIPTION\n\n`go-config-extender` is a utility that helps to work with config files: it loads a JSON config file and ***overrides values by setting environment variables***. This is useful when we are having, i.e., `Dockerfile` or `docker-compose`, consider that we are having application \nconfig file `config.json` and we have to override log level or db `username+passord` based on values in an `.env` file.\n\n## 2. Requirements\n\nTo make this thing work, we have to do the following:\n1. We have to separate *\"normal\"* environment variables from technical (those using for such override);\n2. We should have some relation between `JSON` properties in config and env variable.\n\nConsidering these two restrictions, we decided to have a variable's name pattern that allows it to meet all these requirements.\n\nconsider following example of config:\n```json\n{\n    \"server\": {\n        \"schema\": \"http\",\n        \"address\": \"0.0.0.0\",\n        \"port\": 8182,\n        \"secret_file\": \"./keyfile\"\n    },\n    \"logging\": {\n        \"level\": \"debug\",\n        \"appenders\": [\n            {\n                \"type\": \"rolling_file\",\n                \"enabled\": true,\n                \"level\": \"debug\",\n                \"destination\": {\n                    \"file\": \"./logs/ferrum.log\",\n                    \"max_size\": 100,\n                    \"max_age\": 5,\n                    \"max_backups\": 5,\n                    \"local_time\": true\n                }\n            },\n            {\n                \"type\": \"console\",\n                \"enabled\": true,\n                \"level\": \"debug\"\n            }\n        ],\n        \"http_log\": true,\n        \"http_console_out\": true\n    },\n    \"data_source\": {\n        \"type\": \"redis\",\n        \"source\": \"redis:6379\",\n        \"credentials\": {\n            \"username\": \"ferrum_db\",\n            \"password\": \"FeRRuM000\"\n        },\n        \"options\": {\n            \"namespace\": \"ferrum_1\",\n            \"db_number\": \"0\"\n        }\n    }\n}\n```\n\nAnd we would like to override:\n1. `logging.level` -\u003e `env` variable `__logging.level`\n2. `data_source.username` -\u003e `env` variable `__data_source.username`\n3. `data_source.password` -\u003e `env` variable `__data_source.password`\n\nWhat methods this package have:\n1. `LoadConfig [T any] (configFile string) (T, error)` for loading without overriding\n2. `LoadConfigWithEnv [T any] (configFile string) (T, error)` for loading with override\n\n## 3. Full example\n\nA full example could be found in the test `TestLoadJSONConfigWithEnvOverride` [test_file](./config_loader_test.go)\nIn This test were set 3 variables of different types: `bool`, `int` and `float`\n\nReal App usage will be shown later after this package Release \u0026\u0026 usage in `Ferrum Community Authorization Server`","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwissance%2Fgo-config-extender","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwissance%2Fgo-config-extender","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwissance%2Fgo-config-extender/lists"}