{"id":21502396,"url":"https://github.com/night-codes/easyconfig","last_synced_at":"2025-07-09T20:33:14.728Z","repository":{"id":61626197,"uuid":"542988381","full_name":"night-codes/easyconfig","owner":"night-codes","description":"Multi-source configuration loading library in Go","archived":false,"fork":false,"pushed_at":"2024-10-18T22:12:00.000Z","size":23,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-17T13:46:49.345Z","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/night-codes.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":"2022-09-29T07:48:11.000Z","updated_at":"2024-10-18T22:11:57.000Z","dependencies_parsed_at":"2025-01-23T23:42:19.853Z","dependency_job_id":null,"html_url":"https://github.com/night-codes/easyconfig","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/night-codes/easyconfig","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/night-codes%2Feasyconfig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/night-codes%2Feasyconfig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/night-codes%2Feasyconfig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/night-codes%2Feasyconfig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/night-codes","download_url":"https://codeload.github.com/night-codes/easyconfig/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/night-codes%2Feasyconfig/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264502666,"owners_count":23618671,"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-11-23T18:14:45.580Z","updated_at":"2025-07-09T20:33:14.707Z","avatar_url":"https://github.com/night-codes.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Easyconfig [![Go Reference](https://pkg.go.dev/badge/github.com/night-codes/easyconfig.svg)](https://pkg.go.dev/github.com/night-codes/easyconfig)\n\nEasy-to-use multi source configuration library in Go.\n\n## Documentation\n\n[Docs on pkg.go.dev](https://pkg.go.dev/github.com/night-codes/easyconfig)\n\n## How To Install\n\n```bash\ngo get github.com/night-codes/easyconfig\n```\n\n## Example\n\nThe usage looks like this:\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/night-codes/easyconfig\"\n)\n\ntype (\n\tConfig struct {\n\t\tPostgresUser     string   `json:\"postgresUser\" yaml:\"postgresUser\" dir:\"postgres-user\" env:\"APP_POSTGRES_USER\"`\n\t\tPostgresPassword string   `json:\"postgresPassword\" yaml:\"postgresPassword\"`\n\t\tPostgresHost     string   `json:\"postgresHost\" yaml:\"postgresHost\"`\n\t\tPostgresPort     uint64   `json:\"postgresPort\" yaml:\"postgresPort\"`\n\t\tPostgresDBName   string   `json:\"postgresDBName\" yaml:\"postgresDBName\"`\n\t\tPostgresSSLMode  string   `json:\"postgresSSLMode\" yaml:\"postgresSSLMode\"`\n\t\tSlice            []string `json:\"-\" yaml:\"-\" env:\"slice,:\"` // env list separator is \":\"\n\t\tVersion          string   `json:\"-\" yaml:\"-\" dir:\"-\" env:\"-\"` // ignore field\n\t}\n)\n\nfunc main() {\n\tconfig := \u0026Config{\n\t\tPostgresHost: \"localhost\", // default value\n\t}\n\n\t// Simple configuration load\n\tjsonLoader := easyconfig.JSONSource{Path: \"./config.json\"}\n\tif err := jsonLoader.Load(config); err != nil {\n\t\tfmt.Println(err)\n\t\t// use another loader, for example\n\t\t// ....\n\t}\n\n\t// Multi sources loader\n\tloader := easyconfig.NewLoader(\n\t\t[]easyconfig.Source{\n\t\t\t// all sources are sorted in the order in which data loading from each tip will be attempted\n\t\t\teasyconfig.YAMLSource{Path: \"./config.yaml\"},\n\t\t\teasyconfig.JSONSource{Path: \"./config.json\"},\n\t\t\teasyconfig.TOMLSource{Path: \"./config.toml\"},\n\t\t\teasyconfig.ednSource{Path: \"./config.edn\"},\n\t\t\teasyconfig.EnvFileSource{Prefix: \"APP\", Path: \"./config.env\"},\n\t\t\teasyconfig.DirSource{Path: \"./k8s-secret\"}, // loads configuration from the mounted Secrets or ConfigMap kubernetes directory (file=value)\n\t\t\teasyconfig.EnvSource{Prefix: \"APP\"},        // loads configuration from environment variables\n\t\t\teasyconfig.FlagsSource{},                   // loads configuration from flags\n\t\t},\n\t)\n\n\tloader.Load(config) // collect data from each source\n\tfmt.Printf(\"%v\\n\", config)\n}\n```\n\nYou can use -help flag in your application:\n\n```bash\n❯ go run . -help\n\nUsage:\n    app [arguments]\n\nThe commands are:\n\n    -postgresUser\n        Set value of PostgresUser\n    -postgresPassword\n        Set value of PostgresPassword\n    -postgresHost\n        Set value of PostgresHost. Default: \"localhost\"\n    -postgresPort\n        Set number value of PostgresPort\n    -postgresDBName\n        Set value of PostgresDBName\n    -postgresSSLMode\n        Set value of PostgresSSLMode\n    -slice\n        Set value of Slice\n    -version\n        Set value of Version\n\nEnvironment variables to use:\n\n    APP_POSTGRES_USER\n    APP_POSTGRES_PASSWORD\n    APP_POSTGRES_HOST\n    APP_POSTGRES_PORT\n    APP_POSTGRES_DB_NAME\n    APP_POSTGRES_SSL_MODE\n    APP_SLICE\n\nConfiguration directory files to use:\n\n    postgres-user\n    postgres-password\n    postgres-host\n    postgres-port\n    postgres-db-name\n    postgres-ssl-mode\n    slice\n```\n\n## License\n\nMIT License\n\nCopyright (C) 2022 Oleksiy Chechel (alex.mirrr@gmail.com)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnight-codes%2Feasyconfig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnight-codes%2Feasyconfig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnight-codes%2Feasyconfig/lists"}