{"id":13410850,"url":"https://github.com/heetch/confita","last_synced_at":"2026-02-05T10:21:02.919Z","repository":{"id":48469026,"uuid":"114995309","full_name":"heetch/confita","owner":"heetch","description":"Load configuration in cascade from multiple backends into a struct","archived":false,"fork":false,"pushed_at":"2025-09-30T16:08:58.000Z","size":174,"stargazers_count":505,"open_issues_count":22,"forks_count":50,"subscribers_count":22,"default_branch":"master","last_synced_at":"2025-09-30T18:07:53.365Z","etag":null,"topics":["configuration","configuration-loader","golang","structure","team-boost"],"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/heetch.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2017-12-21T10:49:18.000Z","updated_at":"2025-09-30T16:06:05.000Z","dependencies_parsed_at":"2024-06-18T12:30:09.418Z","dependency_job_id":"61273be2-e068-4d55-85cd-dbc9c1e3dabf","html_url":"https://github.com/heetch/confita","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/heetch/confita","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heetch%2Fconfita","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heetch%2Fconfita/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heetch%2Fconfita/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heetch%2Fconfita/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/heetch","download_url":"https://codeload.github.com/heetch/confita/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heetch%2Fconfita/sbom","scorecard":{"id":459580,"data":{"date":"2025-08-11","repo":{"name":"github.com/heetch/confita","commit":"88e836f3254fac9e7e3dfc55eea371769acc708b"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.6,"checks":[{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":9,"reason":"Found 15/16 approved changesets -- score normalized to 9","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":3,"reason":"4 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 3","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:39: update your workflow using https://app.stepsecurity.io/secureworkflow/heetch/confita/test.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:43: update your workflow using https://app.stepsecurity.io/secureworkflow/heetch/confita/test.yml/master?enable=pin","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/test.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 30 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"39 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GO-2022-0391 / GHSA-6jvc-q2x7-pchv / GHSA-76wf-9vgp-pj7w","Warn: Project is vulnerable to: GO-2022-0635 / GHSA-7f33-f4f5-xwgw","Warn: Project is vulnerable to: GO-2022-0646 / GHSA-f5pg-7wfw-84q9","Warn: Project is vulnerable to: GO-2020-0017 / GHSA-w73w-5m7g-f7qc","Warn: Project is vulnerable to: GO-2021-0053 / GHSA-c3h9-896r-86jm","Warn: Project is vulnerable to: GO-2020-0019 / GHSA-3xh2-74w9-5vxm","Warn: Project is vulnerable to: GO-2024-2947 / GHSA-v6v8-xj6m-xwqh","Warn: Project is vulnerable to: GO-2022-0322 / GHSA-cg3q-j54f-5p7p","Warn: Project is vulnerable to: GO-2022-0229 / GHSA-cjjc-xp8v-855w","Warn: Project is vulnerable to: GO-2020-0012 / GHSA-ffhg-7mh4-33c4","Warn: Project is vulnerable to: GO-2021-0227 / GHSA-3vm4-22fp-5rfm","Warn: Project is vulnerable to: GO-2022-0968 / GHSA-gwc9-m7rh-j2ww","Warn: Project is vulnerable to: GO-2021-0356 / GHSA-8c26-wmh5-6g9v","Warn: Project is vulnerable to: GO-2024-2961","Warn: Project is vulnerable to: GO-2023-2402 / GHSA-45x7-px36-x8w8","Warn: Project is vulnerable to: GO-2024-3321 / GHSA-v778-237x-gjrc","Warn: Project is vulnerable to: GO-2025-3487 / GHSA-hcg3-q754-cr77","Warn: Project is vulnerable to: GO-2022-0536 / GHSA-39qc-96h7-956f / GHSA-hgr8-6h9x-f7q9","Warn: Project is vulnerable to: GO-2022-0236 / GHSA-h86h-8ppg-mxmh","Warn: Project is vulnerable to: GO-2021-0238 / GHSA-83g2-8m93-v3w7","Warn: Project is vulnerable to: GO-2022-0288","Warn: Project is vulnerable to: GO-2022-0969 / GHSA-69cg-p879-7622","Warn: Project is vulnerable to: GO-2022-1144 / GHSA-xrjj-mj9h-534m","Warn: Project is vulnerable to: GO-2023-1571 / GHSA-vvpx-j8f3-3w6h","Warn: Project is vulnerable to: GO-2023-1988 / GHSA-2wrh-6pvc-2jm9","Warn: Project is vulnerable to: GO-2023-2102 / GHSA-4374-p667-p6c8","Warn: Project is vulnerable to: GO-2023-2153 / GHSA-m425-mq94-257g / GHSA-qppj-fm5r-hxr3","Warn: Project is vulnerable to: GO-2024-2687 / GHSA-4v7x-pqxf-cx7m","Warn: Project is vulnerable to: GO-2024-3333","Warn: Project is vulnerable to: GO-2025-3503 / GHSA-qxp5-gwg8-xv66","Warn: Project is vulnerable to: GO-2025-3595 / GHSA-vvgc-356p-c3xw","Warn: Project is vulnerable to: GO-2022-0493 / GHSA-p782-xgp4-8hr8","Warn: Project is vulnerable to: GO-2020-0015 / GHSA-5rcv-m4m3-hfh7","Warn: Project is vulnerable to: GO-2021-0113 / GHSA-ppp9-7jff-5vj2","Warn: Project is vulnerable to: GO-2022-1059 / GHSA-69ch-w2m2-3vjp","Warn: Project is vulnerable to: GO-2024-2631 / GHSA-c5q2-7r4c-mv6g","Warn: Project is vulnerable to: GO-2021-0061 / GHSA-r88r-gmrh-7j83","Warn: Project is vulnerable to: GO-2022-0956 / GHSA-6q6q-88xp-6f2r","Warn: Project is vulnerable to: GO-2020-0036 / GHSA-wxc4-f4m6-wwqv"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-19T10:44:06.784Z","repository_id":48469026,"created_at":"2025-08-19T10:44:06.784Z","updated_at":"2025-08-19T10:44:06.784Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29119231,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-05T09:40:36.738Z","status":"ssl_error","status_checked_at":"2026-02-05T09:36:49.977Z","response_time":65,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["configuration","configuration-loader","golang","structure","team-boost"],"created_at":"2024-07-30T20:01:09.769Z","updated_at":"2026-02-05T10:21:02.912Z","avatar_url":"https://github.com/heetch.png","language":"Go","funding_links":[],"categories":["Configuration","Misc","Go","配置","Uncategorized","配置管理 `配置解析库`","配置管理"],"sub_categories":["Standard CLI","标准CLI","Advanced Console UIs","标准 CLI"],"readme":"![](https://user-images.githubusercontent.com/4570448/40795774-57ad2ae2-6503-11e8-8448-328094f4091f.png)\n\n[![Build Status](https://travis-ci.org/heetch/confita.svg?branch=master)](https://travis-ci.org/heetch/confita)\n[![GoDoc](https://godoc.org/github.com/heetch/confita?status.svg)](https://godoc.org/github.com/heetch/confita)\n[![Go Report Card](https://goreportcard.com/badge/github.com/heetch/confita)](https://goreportcard.com/report/github.com/heetch/confita)\n\nConfita is a library that loads configuration from multiple backends and stores it in a struct.\n\n## Supported backends\n\n- Environment variables\n- JSON files\n- Yaml files\n- Toml files\n- Command line flags\n- [etcd](https://github.com/coreos/etcd)\n- [Consul](https://www.consul.io/)\n- [Vault](https://www.vaultproject.io/)\n- [Amazon SSM](https://docs.aws.amazon.com/systems-manager/latest/userguide/what-is-systems-manager.html)\n\n## Install\n\n```sh\ngo get -u github.com/heetch/confita\n```\n\n## Usage\n\nConfita scans a struct for `config` tags and calls all the backends one after another until the key is found.\nThe value is then converted into the type of the field.\n\n### Struct layout\n\nGo primitives are supported:\n\n```go\ntype Config struct {\n  Host        string        `config:\"host\"`\n  Port        uint32        `config:\"port\"`\n  Timeout     time.Duration `config:\"timeout\"`\n  SomeVal     time.Time     `config:\"someval\"`\n}\n```\n\nTime is expected to be in `RFC3339` format.\n\nBy default, all fields are optional. With the required option, if a key is not found then Confita will return an error.\n\n```go\ntype Config struct {\n  Addr        string        `config:\"addr,required\"`\n  Timeout     time.Duration `config:\"timeout\"`\n}\n```\n\nNested structs are supported too:\n\n```go\ntype Config struct {\n  Host        string        `config:\"host\"`\n  Port        uint32        `config:\"port\"`\n  Timeout time.Duration     `config:\"timeout\"`\n  Database struct {\n    URI string              `config:\"database-uri,required\"`\n  }\n}\n```\n\nIf a field is a slice, Confita will automatically split the config value by commas and fill the slice with each sub value.\n\n```go\ntype Config struct {\n  Endpoints []string `config:\"endpoints\"`\n}\n```\n\nAs a special case, if the field tag is \"-\", the field is always omitted. This is useful if you want to populate this field on your own.\n\n```go\ntype Config struct {\n  // Field is ignored by this package.\n  Field float64 `config:\"-\"`\n\n  // Confita scans any structure recursively, the \"-\" value prevents that.\n  Client http.Client `config:\"-\"`\n}\n```\n\n### Loading configuration\n\nCreating a loader:\n\n```go\nloader := confita.NewLoader()\n```\n\nBy default, a Confita loader loads all the keys from the environment.\nA loader can take other configured backends as parameters.\n\n```go\nloader := confita.NewLoader(\n  env.NewBackend(),\n  file.NewBackend(\"/path/to/config.json\"),\n  file.NewBackend(\"/path/to/config.yaml\"),\n  flags.NewBackend(),\n  etcd.NewBackend(etcdClientv3),\n  consul.NewBackend(consulClient),\n  vault.NewBackend(vaultClient),\n)\n```\n\nLoading configuration:\n\n```go\nerr := loader.Load(context.Background(), \u0026cfg)\n```\n\nSince loading configuration can take time when used with multiple remote backends, context can be used for timeout and cancelation:\n\n```go\nctx, cancel := context.WithTimeout(context.Background(), 5 * time.Second)\ndefer cancel()\nerr := loader.Load(ctx, \u0026cfg)\n```\n\n### Default values\n\nIf a key is not found, Confita won't change the respective struct field. With that in mind, default values can simply be implemented by filling the structure before passing it to Confita.\n\n```go\n\ntype Config struct {\n  Host        string        `config:\"host\"`\n  Port        uint32        `config:\"port\"`\n  Timeout     time.Duration `config:\"timeout\"`\n  Password    string        `config:\"password,required\"`\n}\n\n// default values\ncfg := Config{\n  Host: \"127.0.0.1\",\n  Port: \"5656\",\n  Timeout: 5 * time.Second,\n}\n\nerr := confita.NewLoader().Load(context.Background(), \u0026cfg)\n```\n\n### Backend option\n\nBy default, Confita queries each backend one after another until a key is found. However, in order to avoid some useless processing the `backend` option can be specified to describe in which backend this key is expected to be found.\nThis is especially useful when the location of the key is known beforehand.\n\n```go\ntype Config struct {\n  Host        string        `config:\"host,backend=env\"`\n  Port        uint32        `config:\"port,required,backend=etcd\"`\n  Timeout     time.Duration `config:\"timeout\"`\n}\n```\n\n### Command line flags\n\nThe `flags` backend allows to load individual configuration keys from the command line. The default values are extracted from the struct fields values.\n\nA `short` option is also supported.\n\nTo update usage message on the command line, provide a `description` to the given field.\n\n```go\ntype Config struct {\n  Host        string        `config:\"host,short=h\"`\n  Port        uint32        `config:\"port,short=p\"`\n  Timeout     time.Duration `config:\"timeout,description=timeout (in seconds) for failure\"`\n}\n```\n\n\n```sh\n./bin -h\n\nUsage of ./bin:\n  -host string\n       (default \"127.0.0.1\")\n  -h string\n       (default \"127.0.0.1\")\n  -port int\n       (default 5656)\n  -p int\n       (default 5656)\n  -timeout duration\n       timeout (in seconds) for failure (default 10s)\n```\n\n## License\n\nThe library is released under the MIT license. See LICENSE file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheetch%2Fconfita","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fheetch%2Fconfita","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheetch%2Fconfita/lists"}