{"id":18414760,"url":"https://github.com/zoido/yag-config","last_synced_at":"2025-04-07T11:32:53.346Z","repository":{"id":45297561,"uuid":"258859635","full_name":"zoido/yag-config","owner":"zoido","description":"yet another Go configuration library","archived":false,"fork":false,"pushed_at":"2024-11-27T14:04:30.000Z","size":153,"stargazers_count":5,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-22T17:44:17.488Z","etag":null,"topics":["config","configuration","golang","golang-library","golang-package"],"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/zoido.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2020-04-25T19:43:23.000Z","updated_at":"2024-11-27T14:03:38.000Z","dependencies_parsed_at":"2024-06-21T03:18:45.154Z","dependency_job_id":"3f0e2b9e-c597-4590-8d3f-08edc41d28d3","html_url":"https://github.com/zoido/yag-config","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zoido%2Fyag-config","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zoido%2Fyag-config/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zoido%2Fyag-config/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zoido%2Fyag-config/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zoido","download_url":"https://codeload.github.com/zoido/yag-config/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247645115,"owners_count":20972411,"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":["config","configuration","golang","golang-library","golang-package"],"created_at":"2024-11-06T03:52:15.607Z","updated_at":"2025-04-07T11:32:52.801Z","avatar_url":"https://github.com/zoido.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Yet Another Golang Config Library\n\n[![go reference](https://pkg.go.dev/badge/github.com/zoido/yag-config)](https://pkg.go.dev/github.com/zoido/yag-config)\n[![licence](https://img.shields.io/github/license/zoido/yag-config?style=flat-square)](https://github.com/zoido/yag-config/blob/master/LICENSE)\n![CI](https://img.shields.io/github/actions/workflow/status/zoido/yag-config/go.yaml?style=flat-square\u0026logoColor=white\u0026logo=github)\n[![coverage](https://img.shields.io/codecov/c/github/zoido/yag-config?style=flat-square\u0026logoColor=white\u0026logo=codecov)](https://codecov.io/gh/zoido/yag-config)\n[![go report](https://goreportcard.com/badge/github.com/zoido/yag-config?style=flat-square)](https://goreportcard.com/report/github.com/zoido/yag-config)\n\n## Overview\n\n- obtain configuration values from flags and/or environment variables\n  (flags always take precedence)\n- any variable or struct member can become a destination for the config value\n- define defaults in the native type\n- option define environment variable prefix\n- option to override the environment variable name\n- option to mark options as required\n\n## Example\n\n\u003c!-- markdownlint-disable MD010 MD013 --\u003e\n\n```go\ntype config struct {\n\tStr      string\n\tBool     bool\n\tInt      int\n\tDuration time.Duration\n}\n\ny := yag.New(yag.WithEnvPrefix(\"MY_APP_\"))\ncfg := \u0026config{\n\tStr: \"default str value\",\n\tInt: 42,\n}\n\ny.String(\u0026cfg.Str, \"str\", \"sets Str\")\ny.Bool(\u0026cfg.Bool, \"bool\", \"sets Bool\")\ny.Duration(\u0026cfg.Duration, \"duration\", \"sets Duration\", yag.FromEnv(\"MY_DURATION_VALUE\"))\ny.Int(\u0026cfg.Int, \"int\", \"sets Int\")\n\nargs := []string{\"-str=str flag value\"}\n\n_ = os.Setenv(\"MY_APP_STR\", \"str env value\")\n_ = os.Setenv(\"MY_APP_INT\", \"4\")\n_ = os.Setenv(\"MY_DURATION_VALUE\", \"1h\")\n\nerr := y.Parse(args)\nif err != nil {\n\tfmt.Printf(\"Error: %v\\n\", err)\n\treturn\n}\n\nfmt.Printf(\"config.Str: %v, \", cfg.Str)\nfmt.Printf(\"config.Int: %v, \", cfg.Int)\nfmt.Printf(\"config.Bool: %v, \", cfg.Bool)\nfmt.Printf(\"config.Duration: %v\", cfg.Duration)\n\n// Output:\n// config.Str: str flag value, config.Int: 4, config.Bool: false, config.Duration: 1h0m0s\n```\n\n\u003c!-- markdownlint-enable MD010 MD013 --\u003e\n\n## Supported types\n\n- `str`\n- `int`, `int8`, `int16`, `int32`, `int64`\n- `uint`, `uint8`, `uint16`, `uint32`, `uint64`\n- `float32`, `float64`\n- `bool`\n- `time.Duration`\n- any `flag.Value` implementation (e.g. [(github.com/sgreben/flagvar](https://github.com/sgreben/flagvar))\n\n## Credits\n\nOriginally inspired by flags processing in of\n[Consul agent](https://github.com/hashicorp/consul).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzoido%2Fyag-config","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzoido%2Fyag-config","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzoido%2Fyag-config/lists"}