{"id":22870201,"url":"https://github.com/berquerant/structconfig","last_synced_at":"2025-05-07T15:24:21.469Z","repository":{"id":263195983,"uuid":"889084614","full_name":"berquerant/structconfig","owner":"berquerant","description":"Map default values, environment variables, and command-line arguments to struct tags.","archived":false,"fork":false,"pushed_at":"2025-03-13T14:49:52.000Z","size":128,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-31T11:30:30.952Z","etag":null,"topics":["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/berquerant.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":"2024-11-15T15:25:04.000Z","updated_at":"2025-03-13T14:48:27.000Z","dependencies_parsed_at":"2024-11-16T22:24:17.544Z","dependency_job_id":"1dc14d12-210a-4097-80e3-2d86f086b7ba","html_url":"https://github.com/berquerant/structconfig","commit_stats":null,"previous_names":["berquerant/structconfig"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/berquerant%2Fstructconfig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/berquerant%2Fstructconfig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/berquerant%2Fstructconfig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/berquerant%2Fstructconfig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/berquerant","download_url":"https://codeload.github.com/berquerant/structconfig/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252903659,"owners_count":21822483,"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":["go"],"created_at":"2024-12-13T13:14:07.076Z","updated_at":"2025-05-07T15:24:21.452Z","avatar_url":"https://github.com/berquerant.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Go Report Card](https://goreportcard.com/badge/github.com/berquerant/structconfig)](https://goreportcard.com/report/github.com/berquerant/structconfig)\n[![Go Reference](https://pkg.go.dev/badge/github.com/berquerant/structconfig.svg)](https://pkg.go.dev/github.com/berquerant/structconfig)\n\n# structconfig\n\nMap default values, environment variables, and command-line arguments to struct tags.\n\n# Installation\n\n``` shell\ngo get github.com/berquerant/structconfig\n```\n\n# Examples\n\n## Default values\n\n``` go\ntype T struct {\n  I int `default:\"10\"`\n}\n\nsc := structconfig.New[T]()\nvar got T\nif err := sc.FromDefault(\u0026got); err != nil {\n  panic(err)\n}\n// got.I == 10\n```\n\n## Environment variables\n\n``` go\ntype T struct {\n  I int `name:\"int_value\"`\n}\n\nos.Setenv(\"INT_VALUE\", \"10\")\nsc := structconfig.New[T]()\nvar got T\nif err := sc.FromEnv(\u0026got); err != nil {\n  panic(err)\n}\n// got.I == 10\n```\n\n## Command-line flags ([pflag](https://github.com/spf13/pflag))\n\n``` go\ntype T struct {\n  I int `name:\"int_value\" default:\"10\"`\n}\n\nvar fs *pflag.FlagSet = // ...\nsc := structconfig.New[T]()\nif err := sc.SetFlags(fs); err != nil {\n  panic(err)\n}\nif err := fs.Parse([]string{\"--int_value\", \"100\"}); err != nil {\n  panic(err)\n}\nvar got T\nif err := sc.FromFlags(\u0026got, fs); err != nil {\n  panic(err)\n}\n// got.I == 100\n```\n\n## More examples\n\n- [Merger](example_merger_test.go)\n- [Default, Env, Flag](example_structconfig_test.go)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fberquerant%2Fstructconfig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fberquerant%2Fstructconfig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fberquerant%2Fstructconfig/lists"}