{"id":22385581,"url":"https://github.com/roger-king/go-getenv","last_synced_at":"2025-03-26T20:26:18.971Z","repository":{"id":124462039,"uuid":"264740895","full_name":"roger-king/go-getenv","owner":"roger-king","description":"a simple getenv wrapper to allow for default environment. inspired by python's os.getenv(\"ENV\", default)","archived":false,"fork":false,"pushed_at":"2020-05-17T20:42:56.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-01T02:25:10.052Z","etag":null,"topics":["dotenv","environment-variables","getenv","go"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/roger-king.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2020-05-17T19:26:20.000Z","updated_at":"2020-05-17T20:42:58.000Z","dependencies_parsed_at":null,"dependency_job_id":"2aba3206-fd64-44eb-bcf6-cecc94573204","html_url":"https://github.com/roger-king/go-getenv","commit_stats":{"total_commits":10,"total_committers":1,"mean_commits":10.0,"dds":0.0,"last_synced_commit":"2af2093f33452eee1b5a75c03b4d25087e1f156a"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roger-king%2Fgo-getenv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roger-king%2Fgo-getenv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roger-king%2Fgo-getenv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roger-king%2Fgo-getenv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/roger-king","download_url":"https://codeload.github.com/roger-king/go-getenv/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245729789,"owners_count":20662906,"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":["dotenv","environment-variables","getenv","go"],"created_at":"2024-12-05T01:26:22.214Z","updated_at":"2025-03-26T20:26:18.950Z","avatar_url":"https://github.com/roger-king.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-getenv\n\nA simple getenv utility to support default values to be set. This is a port from python's `os.getenv(\"ENV_KEY\", \"default)`. This utility function will do a few things:\n\n1. Return the passed default value (with a logging message).\n2. Return the environment variable set over the default value\n3. Panic if the Environment variable does not exist and no default value set.\n\n# Installation\n\nInstallation is done using the go get command:\n\n```\n  go get -u github.com/roger-king/go-getenv\n```\n\n# Usage\n\nUsing the utility function is simple. We call the function and pass in as the first arg the `Environment Variable Key` and the `getenv.String(\"some-string\")`.\n\n```\n  import \"github.com/roger-king/go-getenv\"\n\n  port := getenv.EnvOrDefault(\"PORT\", getenv.String(\":5000\"))\n```\n\n## Why `getenv.String(\"some-string\")`\n\nI decided to create a `String()` function because I want to support the ability to pass `nil` as the second or default argument.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froger-king%2Fgo-getenv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Froger-king%2Fgo-getenv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froger-king%2Fgo-getenv/lists"}