{"id":13411111,"url":"https://github.com/joshbetz/config","last_synced_at":"2025-05-08T23:43:46.936Z","repository":{"id":46121720,"uuid":"87007216","full_name":"joshbetz/config","owner":"joshbetz","description":"🛠 A configuration library for Go that parses environment variables, JSON files, and reloads automatically on SIGHUP.","archived":false,"fork":false,"pushed_at":"2021-11-12T16:58:10.000Z","size":22,"stargazers_count":215,"open_issues_count":0,"forks_count":14,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-08T23:43:38.876Z","etag":null,"topics":["config","configuration","env","environment-variables","go","golang","json","sighup"],"latest_commit_sha":null,"homepage":"https://josh.blog/2017/04/go-configure","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/joshbetz.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}},"created_at":"2017-04-02T18:37:05.000Z","updated_at":"2024-10-03T16:17:12.000Z","dependencies_parsed_at":"2022-08-26T13:23:37.490Z","dependency_job_id":null,"html_url":"https://github.com/joshbetz/config","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/joshbetz%2Fconfig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshbetz%2Fconfig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshbetz%2Fconfig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshbetz%2Fconfig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joshbetz","download_url":"https://codeload.github.com/joshbetz/config/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253166474,"owners_count":21864467,"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","env","environment-variables","go","golang","json","sighup"],"created_at":"2024-07-30T20:01:11.472Z","updated_at":"2025-05-08T23:43:46.917Z","avatar_url":"https://github.com/joshbetz.png","language":"Go","funding_links":[],"categories":["配置","Configuration","Go","Uncategorized","配置管理 `配置解析库`","配置管理","Libraries","\u003cspan id=\"组态-configuration\"\u003e组态 Configuration\u003c/span\u003e"],"sub_categories":["标准CLI","Advanced Console UIs","Standard CLI","高级控制台界面","高級控制台界面","标准 CLI","\u003cspan id=\"高级控制台用户界面-advanced-console-uis\"\u003e高级控制台用户界面 Advanced Console UIs\u003c/span\u003e"],"readme":"# config\n\n[![Build Status](https://travis-ci.org/joshbetz/config.svg?branch=master)](https://travis-ci.org/joshbetz/config) [![Go Report Card](https://goreportcard.com/badge/github.com/joshbetz/config)](https://goreportcard.com/report/github.com/joshbetz/config) [![](https://godoc.org/github.com/joshbetz/config?status.svg)](http://godoc.org/github.com/joshbetz/config)\n\n\nA small configuration library for Go that parses environment variables, JSON\nfiles, and reloads automatically on `SIGHUP`.\n\n## Example\n\n```go\nfunc main() {\n\tc := config.New(\"config.json\")\n\n\thttp.HandleFunc(\"/\", func(w http.ResponseWriter, r *http.Request) {\n\t\tvar value string\n\t\tc.Get(\"value\", \u0026value)\n\t\tfmt.Fprintf(w, \"Value: %s\", value)\n\t})\n\n\thttp.ListenAndServe(\":3000\", nil)\n}\n```\n\n![Reload config on SIGHUP](http://i.imgur.com/6H8b6zy.gif)\n\n## API\n\n```go\nfunc New(file string) *Config\n```\n\nConstructor that initializes a Config object and sets up the SIGHUP watcher.\n\n```go\nfunc (config *Config) Get(key string, v interface{}) error\n```\n\nTakes the path to a JSON file, the name of the configuration option, and a\npointer to the variable where the config value will be stored. `v` can be a\npointer to a string, bool, or float64.\n\n```go\nfunc (config *Config) Reload()\n```\n\nReloads the config. Happens automatically on `SIGHUP`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoshbetz%2Fconfig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoshbetz%2Fconfig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoshbetz%2Fconfig/lists"}