{"id":37163646,"url":"https://github.com/limoli/configfacade","last_synced_at":"2026-01-14T19:27:41.457Z","repository":{"id":57612761,"uuid":"153432568","full_name":"limoli/configfacade","owner":"limoli","description":"A simple facade for multiple configurations using different libraries.","archived":false,"fork":false,"pushed_at":"2018-11-19T10:50:22.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-06-20T00:41:50.256Z","etag":null,"topics":["config","facade"],"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/limoli.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":"2018-10-17T09:41:22.000Z","updated_at":"2020-07-12T13:41:23.000Z","dependencies_parsed_at":"2022-09-14T15:10:43.708Z","dependency_job_id":null,"html_url":"https://github.com/limoli/configfacade","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/limoli/configfacade","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/limoli%2Fconfigfacade","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/limoli%2Fconfigfacade/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/limoli%2Fconfigfacade/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/limoli%2Fconfigfacade/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/limoli","download_url":"https://codeload.github.com/limoli/configfacade/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/limoli%2Fconfigfacade/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28432607,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T18:57:19.464Z","status":"ssl_error","status_checked_at":"2026-01-14T18:52:48.501Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["config","facade"],"created_at":"2026-01-14T19:27:40.960Z","updated_at":"2026-01-14T19:27:41.442Z","avatar_url":"https://github.com/limoli.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Config Facade\n[![GoDoc](https://godoc.org/limoli/configfacade?status.svg)](https://godoc.org/github.com/limoli/configfacade)\n[![Go Report Card](https://goreportcard.com/badge/github.com/limoli/configfacade)](https://goreportcard.com/report/github.com/limoli/configfacade)\n[![Maintainability](https://api.codeclimate.com/v1/badges/988c97ce3d1495e953a2/maintainability)](https://codeclimate.com/github/limoli/configfacade/maintainability)\n\nConfig Facade is a simple facade for multiple configurations using different libraries.\n\n# Problem\nMany times we begin projects with different libraries in order to provide configurations for our apps and every time we have to implement new logics for the same features. This is a **big problem of abstraction**.\nWhen you decide to use a specific library, you import it from github and you use it for whole project. But what happens if you need to change library for some reason? You have to refactor everything and implement again the logics if you are enough unlucky.\n\n# Solution\nIt would be nice if a common wrapper could implement the main features without thinking too much about which libraries we have decided to use. In this way, we will be able to use different libraries in the future and extend our projects compatibility.\n\nWhat you will able to do:\n- set a complete configuration in few lines of code\n- choose any compatible library\n \n# Compatible libraries\n- [Viper](https://github.com/limoli/viper)\n\n# Installation\n\n```sh\ndep ensure -add github.com/limoli/configfacade\n``` \n\n# Example\n\n**extra/config/development.yaml**\nIt defines a configuration file with `yaml` format for the development environment.\n```yaml\napp:\n  port: \"8080\"\n```\n\n**main.go**\nIt initialises a configuration instance using Viper library. As for settings, it defines the configuration file to read and the possible environment variables which can override the default configuration value.\n\n```sh\ndep ensure -add github.com/limoli/viper@master\n``` \n\n```go\nimport (\n\t\"github.com/limoli/configfacade\"\n\t\"github.com/limoli/viper\"\n\t\"log\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"runtime\"\n)\n\nvar config configfacade.Config\n\nfunc init() {\n\tvar err error\n\n\t// filepath.Abs uses working directory and it can change during tests\n\t_, currentFilePath, _, _ := runtime.Caller(0)\n\tpath := filepath.Join(filepath.Dir(currentFilePath), \"config\")\n\n\tconfig, err = configfacade.Init(new(viper.Facade), configfacade.Settings{\n\t\tPath:      path,\n\t\tName:      os.Getenv(\"APP_ENV\"),\n\t\tExtension: \"yaml\",\n\t\tEnvVars: map[string]string{\n\t\t\t\"app.db.user\":     \"MYSQL_USER\",\n\t\t\t\"app.db.password\": \"MYSQL_PASSWORD\",\n\t\t\t\"app.db.host\":     \"MYSQL_HOST\",\n\t\t\t\"app.db.port\":     \"MYSQL_PORT\",\n\t\t\t\"app.db.name\":     \"MYSQL_DATABASE\",\n\t\t},\n\t})\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n}\n``` \n\n# Contribute\nWould you like to see a library in the compatible list? \nJust implement the `Config` interface and send a pull request.\n\n```go\ntype Config interface {\n\tLoadFile(path string, filename string, extension string) error\n\tLoadEnvVars(vars map[string]string) error\n\tGet(key string) interface{}\n}\n```\nThe best thing you could do is to **implement this interface directly on the library**.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flimoli%2Fconfigfacade","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flimoli%2Fconfigfacade","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flimoli%2Fconfigfacade/lists"}