{"id":29311508,"url":"https://github.com/abecodes/genv","last_synced_at":"2025-07-07T08:15:04.752Z","repository":{"id":241999719,"uuid":"808344871","full_name":"abecodes/genv","owner":"abecodes","description":"GEneric eNV is a zero dependency package for effortless interaction with env variables","archived":false,"fork":false,"pushed_at":"2024-06-01T11:07:20.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-06-01T12:27:24.204Z","etag":null,"topics":[],"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/abecodes.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-30T21:55:52.000Z","updated_at":"2024-06-01T11:07:23.000Z","dependencies_parsed_at":"2024-06-01T12:27:10.964Z","dependency_job_id":null,"html_url":"https://github.com/abecodes/genv","commit_stats":null,"previous_names":["abecodes/genv"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/abecodes/genv","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abecodes%2Fgenv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abecodes%2Fgenv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abecodes%2Fgenv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abecodes%2Fgenv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abecodes","download_url":"https://codeload.github.com/abecodes/genv/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abecodes%2Fgenv/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264040974,"owners_count":23548077,"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":[],"created_at":"2025-07-07T08:15:03.315Z","updated_at":"2025-07-07T08:15:04.744Z","avatar_url":"https://github.com/abecodes.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 👓 **GENV**\n\n**GE**neric e**NV** is a zero dependency package for effortless interaction with env variables.\n\n## 📦 Install\n\n```bash\ngo get github.com/abecodes/genv\n```\n\n## 💻 Usage\n\n**GENV** provides a `Get` and a `GetWithDefault` function.\n\nUsing them is pretty straight forward, but there are two constraints:\n\n- If the value for a given env variable does not match the requested type, the \\*requested types **default value\\*** will be returned\n- If a value of `time.Time` is requested, the string in the env needs to be in RFC1123 format (\"Thu, 30 May 2024 21:01:37 GMT\")\n\n**GENV** supports all basic types as well as `time.Time` (RFC1123) and `time.Duration`.\n\n### Get\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n\n    \"github.com/abecodes/genv\"\n)\n\nfunc main() {\n    // This will retrieve the value set for env var \"HOME\" and return the value as string\n    home := genv.Get[string](\"HOME\")\n\n    // prints: \"(string) /your/home/path\"\n    fmt.Printf(\"(%T) %v\\n\", home, home)\n\n    // This will retrieve the value set for env var \"KITTY_PID\" and return the value as int\n    pid := genv.Get[int](\"KITTY_PID\")\n\n    // prints: \"(int) 1234\"\n    fmt.Printf(\"(%T) %v\\n\", pid, pid)\n\n    // Since everything in the env is a string, we can return the value for \"KITTY_PID\" as string as well\n    pidStr := genv.Get[string](\"KITTY_PID\")\n\n    // prints: \"(string) 1234\"\n    fmt.Printf(\"(%T) %v\\n\", pidStr, pidStr)\n\n    // This does not work the other way around. If we try to turn a `string` type into an `int` type,\n    // we will just receive the `int` type default value\n    homeInt := genv.Get[int](\"HOME\")\n\n    // prints: \"(int) 0\"\n    fmt.Printf(\"(%T) %v\\n\", homeInt, homeInt)\n}\n```\n\n### GetWithDefault\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n\n    \"github.com/abecodes/genv\"\n)\n\nfunc main() {\n    // Since no value exists for this key, the default will be returned\n    str := genv.GetWithDefault[string](\"DOES_NOT_EXIST\", \"hello\")\n\n    // prints: \"(string) hello\"\n    fmt.Printf(\"(%T) %v\\n\", str, str)\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabecodes%2Fgenv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabecodes%2Fgenv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabecodes%2Fgenv/lists"}