{"id":18292247,"url":"https://github.com/zachcheung/eflag","last_synced_at":"2025-04-09T07:54:47.385Z","repository":{"id":216226213,"uuid":"740295417","full_name":"zachcheung/eflag","owner":"zachcheung","description":"Environment Variable Flag Overrides","archived":false,"fork":false,"pushed_at":"2024-01-23T08:44:44.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-01-23T10:15:11.482Z","etag":null,"topics":["flag","go"],"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/zachcheung.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-01-08T03:40:35.000Z","updated_at":"2024-05-30T07:53:45.392Z","dependencies_parsed_at":"2024-01-23T10:11:24.357Z","dependency_job_id":"b6f214f2-c67d-4e59-a0fc-786aff1124a0","html_url":"https://github.com/zachcheung/eflag","commit_stats":null,"previous_names":["zachcheung/eflag"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zachcheung%2Feflag","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zachcheung%2Feflag/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zachcheung%2Feflag/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zachcheung%2Feflag/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zachcheung","download_url":"https://codeload.github.com/zachcheung/eflag/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247999852,"owners_count":21031044,"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":["flag","go"],"created_at":"2024-11-05T14:17:29.811Z","updated_at":"2025-04-09T07:54:47.357Z","avatar_url":"https://github.com/zachcheung.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# eflag - Environment Variable Flag Overrides\n\n`eflag` is designed to override flag values using environment variables when they are not set explicitly.\n\nFlag value precedence (from greatest to least):\n\n1. explicitly set flag\n2. environment variable\n3. flag default value\n\n## Installation\n\n```shell\ngo get github.com/zachcheung/eflag\n```\n\n## Usage\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/zachcheung/eflag\"\n)\n\nfunc main() {\n\tvar (\n\t\thost  string\n\t\tport  int\n\t\tdebug bool\n\t)\n\n\teflag.Var(\u0026host, \"host\", \"localhost\", \"host\", \"\")\n\teflag.Var(\u0026port, \"port\", 8000, \"port\", \"-\")\n\teflag.Var(\u0026debug, \"debug\", false, \"debug\", \"\")\n\n\teflag.SetPrefix(\"myapp\") // Optionally set prefix for environment variables\n\teflag.Parse()\n\n\tfmt.Println(\"host:\", host)   // Environment variable \"MYAPP_HOST\" will overrides default \"localhost\" if it's set\n\tfmt.Println(\"port:\", port)   // Ignores environment variable \"MYAPP_PORT\"\n\tfmt.Println(\"debug:\", debug) // MYAPP_DEBUG=true vs -debug=false\n}\n```\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzachcheung%2Feflag","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzachcheung%2Feflag","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzachcheung%2Feflag/lists"}