{"id":16304834,"url":"https://github.com/moznion/envs","last_synced_at":"2025-10-25T14:30:27.226Z","repository":{"id":38885478,"uuid":"434313033","full_name":"moznion/envs","owner":"moznion","description":"a mapper of ENVironment variables to Structure for Go","archived":false,"fork":false,"pushed_at":"2024-11-24T08:37:01.000Z","size":10,"stargazers_count":3,"open_issues_count":2,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-31T07:34:18.406Z","etag":null,"topics":["environment-variables","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/moznion.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":"2021-12-02T17:25:19.000Z","updated_at":"2021-12-03T02:01:21.000Z","dependencies_parsed_at":"2023-11-08T12:39:21.024Z","dependency_job_id":"52508585-7978-4a53-9d6f-6487e010c0f8","html_url":"https://github.com/moznion/envs","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moznion%2Fenvs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moznion%2Fenvs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moznion%2Fenvs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moznion%2Fenvs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/moznion","download_url":"https://codeload.github.com/moznion/envs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238155431,"owners_count":19425709,"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":["environment-variables","go"],"created_at":"2024-10-10T21:04:56.430Z","updated_at":"2025-10-25T14:30:26.898Z","avatar_url":"https://github.com/moznion.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# envs [![.github/workflows/check.yml](https://github.com/moznion/envs/actions/workflows/check.yml/badge.svg)](https://github.com/moznion/envs/actions/workflows/check.yml) [![codecov](https://codecov.io/gh/moznion/envs/branch/main/graph/badge.svg?token=81AO4XSLSH)](https://codecov.io/gh/moznion/envs)\n\na mapper of \u003cb\u003eENV\u003c/b\u003eironment variables to a \u003cb\u003eS\u003c/b\u003etructure for Go.\n\nThis library maps the environment variables to the struct according to the fields' types and tags.  \nCurrently, it supports the following field types: string, int64, float64, bool, and the pointer for them.\n\n## Synopsis\n\nBasic usage:\n\n```go\nimport (\n\t\"fmt\"\n\t\"os\"\n\n\t\"github.com/moznion/envs\"\n)\n\ntype StructuredEnv struct {\n\tFoo     string  `envs:\"FOO\"`\n\tBar     int64   `envs:\"BAR\"`\n\tBuz     float64 `envs:\"BUZ\"`\n\tQux     bool    `envs:\"QUX\"`\n\tFooBar  string  `envs:\"FOOBAR,allowempty\"`\n\tNothing string\n}\n\nfunc main() {\n\t_ = os.Setenv(\"FOO\", \"string-value\")\n\t_ = os.Setenv(\"BAR\", \"65535\")\n\t_ = os.Setenv(\"BUZ\", \"123.456\")\n\t_ = os.Setenv(\"QUX\", \"true\")\n\n\tvar e StructuredEnv\n\terr := envs.Unmarshal(\u0026e)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfmt.Printf(\"structured envvar:\\n\")\n\tfmt.Printf(\"    Foo     =\u003e \\\"%s\\\"\\n\", e.Foo)\n\tfmt.Printf(\"    Bar     =\u003e %d\\n\", e.Bar)\n\tfmt.Printf(\"    Buz     =\u003e %f\\n\", e.Buz)\n\tfmt.Printf(\"    Qux     =\u003e %v\\n\", e.Qux)\n\tfmt.Printf(\"    FooBar  =\u003e \\\"%s\\\"\\n\", e.FooBar)\n\tfmt.Printf(\"    Nothing =\u003e \\\"%s\\\"\\n\", e.Nothing)\n\n\t// Output:\n\t// structured envvar:\n\t//     Foo     =\u003e \"string-value\"\n\t//     Bar     =\u003e 65535\n\t//     Buz     =\u003e 123.456000\n\t//     Qux     =\u003e true\n\t//     FooBar  =\u003e \"\"\n\t//     Nothing =\u003e \"\"\n}\n```\n\nPointer based usage:\n\n```go\nimport (\n\t\"fmt\"\n\t\"os\"\n\n\t\"github.com/moznion/envs\"\n)\n\ntype PtrStructuredEnv struct {\n\tFoo     *string  `envs:\"FOO\"`\n\tBar     *int64   `envs:\"BAR\"`\n\tBuz     *float64 `envs:\"BUZ\"`\n\tQux     *bool    `envs:\"QUX\"`\n\tFooBar  *string  `envs:\"FOOBAR,allowempty\"`\n\tNothing *string\n}\n\nfunc main() {\n\t_ = os.Setenv(\"FOO\", \"string-value\")\n\t_ = os.Setenv(\"BAR\", \"65535\")\n\t_ = os.Setenv(\"BUZ\", \"123.456\")\n\t_ = os.Setenv(\"QUX\", \"true\")\n\n\tvar pe PtrStructuredEnv\n\terr = envs.Unmarshal(\u0026pe)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfmt.Printf(\"pointer based structured envvar:\\n\")\n\tfmt.Printf(\"    Foo     =\u003e \\\"%s\\\"\\n\", *pe.Foo)\n\tfmt.Printf(\"    Bar     =\u003e %d\\n\", *pe.Bar)\n\tfmt.Printf(\"    Buz     =\u003e %f\\n\", *pe.Buz)\n\tfmt.Printf(\"    Qux     =\u003e %v\\n\", *pe.Qux)\n\tfmt.Printf(\"    FooBar  =\u003e %v\\n\", pe.FooBar)\n\tfmt.Printf(\"    Nothing =\u003e %v\\n\", pe.Nothing)\n\n\t// Output:\n\t// pointer based structured envvar:\n\t//     Foo     =\u003e \"string-value\"\n\t//     Bar     =\u003e 65535\n\t//     Buz     =\u003e 123.456000\n\t//     Qux     =\u003e true\n\t//     FooBar  =\u003e \u003cnil\u003e\n\t//     Nothing =\u003e \u003cnil\u003e\n}\n```\n\nand examples are [here](./example_test.go)\n\n## Documentations\n\n[![GoDoc](https://godoc.org/github.com/moznion/envs?status.svg)](https://godoc.org/github.com/moznion/envs)\n\n## Author\n\nmoznion (\u003cmoznion@mail.moznion.net\u003e)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoznion%2Fenvs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmoznion%2Fenvs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoznion%2Fenvs/lists"}