{"id":13411028,"url":"https://github.com/ian-kent/gofigure","last_synced_at":"2025-04-12T05:54:07.523Z","repository":{"id":23728069,"uuid":"27101299","full_name":"ian-kent/gofigure","owner":"ian-kent","description":"Go configuration made easy!","archived":false,"fork":false,"pushed_at":"2019-09-15T00:17:39.000Z","size":34,"stargazers_count":68,"open_issues_count":1,"forks_count":7,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-12T05:54:01.192Z","etag":null,"topics":[],"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/ian-kent.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-11-25T00:12:40.000Z","updated_at":"2024-09-01T12:51:34.000Z","dependencies_parsed_at":"2022-08-22T03:31:17.325Z","dependency_job_id":null,"html_url":"https://github.com/ian-kent/gofigure","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ian-kent%2Fgofigure","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ian-kent%2Fgofigure/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ian-kent%2Fgofigure/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ian-kent%2Fgofigure/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ian-kent","download_url":"https://codeload.github.com/ian-kent/gofigure/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248525156,"owners_count":21118616,"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":[],"created_at":"2024-07-30T20:01:10.931Z","updated_at":"2025-04-12T05:54:07.500Z","avatar_url":"https://github.com/ian-kent.png","language":"Go","funding_links":[],"categories":["配置","Configuration","Uncategorized","Miscellaneous","\u003cspan id=\"组态-configuration\"\u003e组态 Configuration\u003c/span\u003e","配置管理 `配置解析库`","配置管理"],"sub_categories":["标准CLI","Advanced Console UIs","Standard CLI","\u003cspan id=\"高级控制台用户界面-advanced-console-uis\"\u003e高级控制台用户界面 Advanced Console UIs\u003c/span\u003e","标准 CLI"],"readme":"gofigure  [![GoDoc](https://godoc.org/github.com/ian-kent/gofigure?status.svg)](https://godoc.org/github.com/ian-kent/gofigure) [![Build Status](https://travis-ci.org/ian-kent/gofigure.svg?branch=master)](https://travis-ci.org/ian-kent/gofigure) [![Coverage Status](https://coveralls.io/repos/ian-kent/gofigure/badge.png?branch=master)](https://coveralls.io/r/ian-kent/gofigure?branch=master)\n========\n\nGo configuration made easy!\n\n- Just define a struct and call Gofigure\n- Supports strings, ints/uints/floats, slices and nested structs\n- Supports environment variables and command line flags\n\nRequires Go 1.2+ because of differences in Go's flag package.\n\n### Example\n\n`go get github.com/ian-kent/gofigure`\n\n```go\npackage main\n\nimport \"github.com/ian-kent/gofigure\"\n\ntype config struct {\n  gofigure interface{} `envPrefix:\"BAR\" order:\"flag,env\"`\n  RemoteAddr string `env:\"REMOTE_ADDR\" flag:\"remote-addr\" flagDesc:\"Remote address\"`\n  LocalAddr  string `env:\"LOCAL_ADDR\" flag:\"local-addr\" flagDesc:\"Local address\"`\n  NumCPU int `env:\"NUM_CPU\" flag:\"num-cpu\" flagDesc:\"Number of CPUs\"`\n  Sources []string `env:\"SOURCES\" flag:\"source\" flagDesc:\"Source URL (can be provided multiple times)\"`\n  Numbers []int `env:\"NUMBERS\" flag:\"number\" flagDesc:\"Number (can be provided multiple times)\"`\n  Advanced struct{\n      MaxBytes int64 `env:\"MAX_BYTES\" flag:\"max-bytes\" flagDesc:\"Max bytes\"`\n      MaxErrors int64  `env:\"MAX_ERRORS\" flag:\"max-errors\" flagDesc:\"Max errors\"`\n  }\n}\n\nfunc main() {\n  var cfg config\n  err := gofigure.Gofigure(\u0026cfg)\n  if err != nil {\n    log.Fatal(err)\n  }\n  // use cfg\n}\n```\n\n### gofigure field\n\nThe gofigure field is used to configure Gofigure.\n\nThe `order` tag is used to set configuration source order, e.g.\nenvironment variables first then command line options second.\n\nAny field matching `camelCase` format will be parsed into `camel`\nand `case`, and passed to the source matching `camel`.\n\nFor example, the `envPrefix` field is split into `env` and `prefix`,\nand the tag value is passed to the environment variable source as\nthe `prefix` parameter.\n\n### Arrays and environment variables\n\nArray support for environment variables is currently experimental.\n\nTo enable it, set `GOFIGURE_ENV_ARRAY=1`.\n\nWhen enabled, the environment variable is split on commas, e.g.\n\n```\nstruct {\n    EnvArray []string `env:\"MY_ENV_VAR\"`\n}\n\nMY_ENV_VAR=a,b,c\n\nEnvArray = []string{\"a\", \"b\", \"c\"}\n```\n\n### Licence\n\nCopyright ©‎ 2014, Ian Kent (http://www.iankent.eu).\n\nReleased under MIT license, see [LICENSE](LICENSE.md) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fian-kent%2Fgofigure","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fian-kent%2Fgofigure","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fian-kent%2Fgofigure/lists"}