{"id":22385261,"url":"https://github.com/acoshift/configfile","last_synced_at":"2025-07-31T04:33:04.582Z","repository":{"id":46538429,"uuid":"88499216","full_name":"acoshift/configfile","owner":"acoshift","description":"Read config from file","archived":false,"fork":false,"pushed_at":"2023-07-12T09:30:43.000Z","size":34,"stargazers_count":7,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-06-19T00:26:13.339Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/acoshift.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":"2017-04-17T10:49:44.000Z","updated_at":"2023-05-24T10:03:48.000Z","dependencies_parsed_at":"2024-06-19T00:06:46.305Z","dependency_job_id":"c3d5b4a6-0df5-4992-97e2-811fb50c2ada","html_url":"https://github.com/acoshift/configfile","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acoshift%2Fconfigfile","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acoshift%2Fconfigfile/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acoshift%2Fconfigfile/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acoshift%2Fconfigfile/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/acoshift","download_url":"https://codeload.github.com/acoshift/configfile/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228216519,"owners_count":17886571,"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-12-05T01:22:31.474Z","updated_at":"2024-12-05T01:22:32.442Z","avatar_url":"https://github.com/acoshift.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# configfile\n\n![Build Status](https://github.com/acoshift/configfile/actions/workflows/test.yaml/badge.svg?branch=master)\n[![codecov](https://codecov.io/gh/acoshift/configfile/branch/master/graph/badge.svg)](https://codecov.io/gh/acoshift/configfile)\n[![Go Report Card](https://goreportcard.com/badge/github.com/acoshift/configfile)](https://goreportcard.com/report/github.com/acoshift/configfile)\n[![GoDoc](https://godoc.org/github.com/acoshift/configfile?status.svg)](https://godoc.org/github.com/acoshift/configfile)\n\nRead config from file, useful when read data from kubernetes configmaps, and secret.\n\n## Example\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"net/http\"\n\n    \"github.com/acoshift/configfile\"\n    \"github.com/garyburd/redigo/redis\"\n)\n\nvar config = configfile.NewReader(\"config\")\n\nvar (\n    addr      = config.StringDefault(\"addr\", \":8080\")\n    redisAddr = config.MustString(\"redis_addr\")\n    redisPass = config.String(\"redis_pass\")\n    redisDB   = config.Int(\"redis_db\")\n)\n\nfunc main() {\n    pool := redis.Pool{\n        Dial: func() (redis.Conn, error) {\n            return redis.Dial(\n                \"tcp\",\n                redisAddr,\n                redis.DialPassword(redisPass),\n                redis.DialDatabase(redisDB),\n            )\n        },\n    }\n\n    http.HandleFunc(\"/\", func(w http.ResponseWriter, r *http.Request) {\n        c := pool.Get()\n        defer c.Close()\n        cnt, err := redis.Int64(c.Do(\"INCR\", \"cnt\"))\n        if err != nil {\n            http.Error(w, err.Error(), http.StatusInternalServerError)\n            return\n        }\n        fmt.Fprintf(w, \"count: %d\", cnt)\n    })\n\n    http.ListenAndServe(addr, nil)\n}\n```\n\n## Example YAML\n\n```go\npackage main\n\nimport (\n    \"log\"\n    \"net/http\"\n\n    \"github.com/acoshift/configfile\"\n)\n\nfunc main() {\n    var config = configfile.NewReader(\"testdata/config.yaml\")\n    // or use NewYAMLReader\n    var config = configfile.NewYAMLReader(\"testdata/config.yaml\")\n\n    log.Println(config.Bool(\"data1\")) // true\n    log.Println(config.String(\"data2\")) // false\n    log.Println(config.Int(\"data3\")) // 9\n    log.Println(config.Int(\"data4\")) // 0\n    log.Println(config.String(\"empty\")) // \"\"\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facoshift%2Fconfigfile","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Facoshift%2Fconfigfile","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facoshift%2Fconfigfile/lists"}