{"id":23510837,"url":"https://github.com/danielkov/lazyenv","last_synced_at":"2025-10-05T10:40:32.399Z","repository":{"id":59045858,"uuid":"529696122","full_name":"danielkov/lazyenv","owner":"danielkov","description":"GoLang library for retrieving environment variables in a -lazy- efficient way","archived":false,"fork":false,"pushed_at":"2022-09-01T15:00:21.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-26T20:45:24.859Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danielkov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-08-27T21:01:22.000Z","updated_at":"2022-09-01T11:29:19.000Z","dependencies_parsed_at":"2022-09-11T04:52:28.858Z","dependency_job_id":null,"html_url":"https://github.com/danielkov/lazyenv","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/danielkov/lazyenv","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielkov%2Flazyenv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielkov%2Flazyenv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielkov%2Flazyenv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielkov%2Flazyenv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danielkov","download_url":"https://codeload.github.com/danielkov/lazyenv/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielkov%2Flazyenv/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278444495,"owners_count":25987788,"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","status":"online","status_checked_at":"2025-10-05T02:00:06.059Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-12-25T12:12:34.639Z","updated_at":"2025-10-05T10:40:32.359Z","avatar_url":"https://github.com/danielkov.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Go `lazyenv`\n\n## Installation\n\n```bash\ngo get -u github.com/danielkov/lazyenv\n```\n\n## Usage\n\n```go\npackage main\n\nimport (\n  \"fmt\"\n  \"github.com/danielkov/lazyenv\"\n)\n\nfunc main() {\n  fmt.Println(lazyenv.Get(\"FOO\"), lazyenv.Required[string])\n}\n```\n\nResetting the cache:\n\n```go\nlazyenv.Reset()\n```\n\nImplementing a custom mapper:\n\n```go\nfunc MapOf[K comparable, V any](keyMapper lazyenv.Mapper[K], valueSeparator string, valueMapper lazyenv.Mapper[V], entrySeparator string) lazyenv.Mapper[map[K]V] {\n\treturn func(value string) (map[K]V, error) {\n\t\tvalues := strings.Split(value, entrySeparator)\n\t\tresults := make(map[K]V, len(values))\n\t\tfor _, v := range values {\n\t\t\tkv := strings.Split(v, valueSeparator)\n\t\t\tif len(kv) != 2 {\n\t\t\t\treturn nil, errors.New(\"invalid map value: \" + v)\n\t\t\t}\n\t\t\tk, err := keyMapper(kv[0])\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tv, err := valueMapper(kv[1])\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tresults[k] = v\n\t\t}\n\t\treturn results, nil\n\t}\n}\n\nfunc main() {\n\tvalue, err := lazyenv.Get(\"TEST_MAP\", lazyenv.Required[map[string]string], MapOf(lazyenv.String, \"=\", lazyenv.String, \",\"))\n}\n```\n\n## Explanation\n\nIf you want to read my journal of how and why I've created this library, [here's a link to my blog post on Dev.to](https://dev.to/danielkov/taking-go-generics-for-a-spin-29l4).\n\n## Contributing\n\nPR's are welcome! Please see the [contributing guide](/CONTRIBUTING.md) for more information.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielkov%2Flazyenv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielkov%2Flazyenv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielkov%2Flazyenv/lists"}