{"id":23480045,"url":"https://github.com/yuseferi/envyaml","last_synced_at":"2026-01-24T15:37:03.061Z","repository":{"id":257783235,"uuid":"859364089","full_name":"yuseferi/envyaml","owner":"yuseferi","description":"env Yaml is a configuration loader from Yaml file with enviromental variable that helps to have secret placeholders in yaml file.","archived":false,"fork":false,"pushed_at":"2025-12-25T22:48:40.000Z","size":51,"stargazers_count":17,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-27T09:08:44.668Z","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":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yuseferi.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":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-09-18T14:36:39.000Z","updated_at":"2025-12-25T22:45:23.000Z","dependencies_parsed_at":"2024-09-20T06:42:24.313Z","dependency_job_id":null,"html_url":"https://github.com/yuseferi/envyaml","commit_stats":null,"previous_names":["yuseferi/envyaml"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/yuseferi/envyaml","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuseferi%2Fenvyaml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuseferi%2Fenvyaml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuseferi%2Fenvyaml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuseferi%2Fenvyaml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yuseferi","download_url":"https://codeload.github.com/yuseferi/envyaml/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuseferi%2Fenvyaml/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28730323,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-24T10:24:43.181Z","status":"ssl_error","status_checked_at":"2026-01-24T10:24:36.112Z","response_time":89,"last_error":"SSL_read: 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":[],"created_at":"2024-12-24T20:00:46.806Z","updated_at":"2026-01-24T15:37:03.055Z","avatar_url":"https://github.com/yuseferi.png","language":"Go","funding_links":[],"categories":["Configuration","Recently Updated","配置"],"sub_categories":["Standard CLI","[Dec 24, 2024](/content/2024/12/24/README.md)","标准CLI"],"readme":"\u003cdiv align=\"center\"\u003e\n\n# 🔐 envYaml\n\n### Seamlessly merge YAML configuration with environment variables\n\n[![Go Version](https://img.shields.io/badge/Go-1.25+-00ADD8?style=for-the-badge\u0026logo=go\u0026logoColor=white)](https://go.dev/)\n[![codecov](https://img.shields.io/codecov/c/github/yuseferi/envyaml?style=for-the-badge\u0026logo=codecov\u0026logoColor=white)](https://codecov.io/github/yuseferi/envyaml)\n[![CI](https://img.shields.io/github/actions/workflow/status/yuseferi/envyaml/ci.yml?style=for-the-badge\u0026logo=github\u0026label=CI)](https://github.com/yuseferi/envyaml/actions/workflows/ci.yml)\n[![Go Report Card](https://goreportcard.com/badge/github.com/yuseferi/envyaml?style=for-the-badge)](https://goreportcard.com/report/github.com/yuseferi/envyaml)\n[![License](https://img.shields.io/badge/License-GPL_v3-blue?style=for-the-badge)](LICENSE)\n[![Release](https://img.shields.io/github/v/release/yuseferi/envyaml?style=for-the-badge\u0026logo=github)](https://github.com/yuseferi/envyaml/releases)\n\n\u003cp\u003e\n\u003cimg src=\"https://github.com/user-attachments/assets/b6b5bbc6-f9d7-4d2f-b5c8-e86ce0e0fd9b\" width=\"280\" alt=\"envYaml Logo\" /\u003e\n\u003c/p\u003e\n\n**Keep your configuration clean. Keep your secrets safe.**\n\n[Installation](#-installation) •\n[Quick Start](#-quick-start) •\n[Features](#-features) •\n[Examples](#-examples) •\n[Contributing](#-contributing)\n\n---\n\n\u003c/div\u003e\n\n## 🎯 The Problem\n\nYou love YAML for configuration—it's clean, readable, and organized. But what about sensitive data like API keys, database passwords, and tokens? Hardcoding them is a security nightmare. 😱\n\n## ✨ The Solution\n\n**envYaml** bridges the gap between clean YAML configuration and secure environment variable management. Reference environment variables directly in your YAML files, and envYaml handles the rest!\n\n```yaml\n# config.yml - Clean and secure! 🔒\ndatabase:\n  host: localhost\n  port: 5432\n  password: ${DB_PASSWORD}  # Loaded from environment\n\napi:\n  key: ${API_KEY}           # Never committed to git\n  secret: ${API_SECRET}     # Always secure\n```\n\n## 🚀 Installation\n\n```bash\ngo get github.com/yuseferi/envyaml@latest\n```\n\n**Requirements:** Go 1.25+\n\n## ⚡ Quick Start\n\n**1. Create your YAML configuration:**\n\n```yaml\n# config.yml\nhost: localhost\nport: 3606\npassword: ${DB_PASSWORD}\n```\n\n**2. Define your config struct:**\n\n```go\ntype Config struct {\n    Host     string `yaml:\"host\" env:\"HOST\"`\n    Port     int    `yaml:\"port\" env:\"PORT\"`\n    Password string `yaml:\"password\" env:\"DB_PASSWORD,required\"`\n}\n```\n\n**3. Load and use:**\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"log\"\n    \n    \"github.com/yuseferi/envyaml\"\n)\n\nfunc main() {\n    var cfg Config\n    \n    if err := envyaml.LoadConfig(\"config.yml\", \u0026cfg); err != nil {\n        log.Fatal(err)\n    }\n    \n    fmt.Printf(\"Connected to %s:%d\\n\", cfg.Host, cfg.Port)\n}\n```\n\n## 🎨 Features\n\n| Feature | Description |\n|---------|-------------|\n| 🔄 **Seamless Integration** | Combine YAML files with environment variables effortlessly |\n| ✅ **Required Variables** | Mark critical env vars as required with automatic validation |\n| 🏷️ **Struct Tags** | Use familiar `yaml` and `env` struct tags |\n| 🛡️ **Type Safety** | Full Go type safety with automatic type conversion |\n| 📦 **Zero Config** | Works out of the box with sensible defaults |\n| 🪶 **Lightweight** | Minimal dependencies, maximum performance |\n\n## 📚 Examples\n\n### Required Environment Variables\n\nMark sensitive variables as required to fail fast if they're missing:\n\n```go\ntype Config struct {\n    Host     string `yaml:\"host\" env:\"HOST\"`\n    Port     int    `yaml:\"port\" env:\"PORT\"`\n    Password string `yaml:\"password\" env:\"DB_PASSWORD,required\"` // 👈 Required!\n}\n\nvar cfg Config\nerr := envyaml.LoadConfig(\"config.yml\", \u0026cfg)\nif err != nil {\n    // Error: failed to parse environment variables: env: required environment variable \"DB_PASSWORD\" is not set\n    log.Fatal(err)\n}\n```\n\n### Complete Working Example\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"log\"\n    \"os\"\n    \n    \"github.com/yuseferi/envyaml\"\n)\n\ntype DatabaseConfig struct {\n    Host     string `yaml:\"host\" env:\"DB_HOST\"`\n    Port     int    `yaml:\"port\" env:\"DB_PORT\"`\n    Username string `yaml:\"username\" env:\"DB_USER\"`\n    Password string `yaml:\"password\" env:\"DB_PASSWORD,required\"`\n    Database string `yaml:\"database\" env:\"DB_NAME\"`\n}\n\ntype Config struct {\n    Database DatabaseConfig `yaml:\"database\"`\n    Debug    bool           `yaml:\"debug\" env:\"DEBUG\"`\n}\n\nfunc main() {\n    // Set environment variables (in production, these come from your environment)\n    os.Setenv(\"DB_PASSWORD\", \"super_secret_password\")\n    \n    var cfg Config\n    if err := envyaml.LoadConfig(\"config.yml\", \u0026cfg); err != nil {\n        log.Fatalf(\"Failed to load config: %v\", err)\n    }\n    \n    fmt.Printf(\"Database: %s@%s:%d/%s\\n\", \n        cfg.Database.Username,\n        cfg.Database.Host, \n        cfg.Database.Port,\n        cfg.Database.Database,\n    )\n}\n```\n\nWith this `config.yml`:\n\n```yaml\ndatabase:\n  host: localhost\n  port: 5432\n  username: admin\n  password: ${DB_PASSWORD}\n  database: myapp\n\ndebug: false\n```\n\n**Output:**\n```\nDatabase: admin@localhost:5432/myapp\n```\n\n## 🏗️ How It Works\n\n```\n┌─────────────────┐     ┌─────────────────┐     ┌─────────────────┐\n│   YAML File     │     │   Environment   │     │   Go Struct     │\n│                 │     │   Variables     │     │                 │\n│  host: localhost│     │                 │     │  Host: localhost│\n│  port: 3606     │ ──► │  DB_PASSWORD=   │ ──► │  Port: 3606     │\n│  password: ${..}│     │  \"secret123\"    │     │  Password: ...  │\n└─────────────────┘     └─────────────────┘     └─────────────────┘\n        │                       │                       │\n        └───────────────────────┴───────────────────────┘\n                            envYaml\n```\n\n1. **Read** - Parse your YAML configuration file\n2. **Merge** - Overlay environment variables using struct tags\n3. **Validate** - Ensure required variables are present\n4. **Return** - Provide a fully populated, type-safe config struct\n\n## 🛠️ Development\n\nThis project uses [Task](https://taskfile.dev) for managing development tasks.\n\n```bash\n# Build the project\ntask build\n\n# Run tests\ntask test\n\n# Run tests with coverage\ntask test-coverage\n\n# Clean generated files\ntask clean\n\n# Run all tasks\ntask all\n```\n\n## 🤝 Contributing\n\nWe love contributions! ❤️\n\n1. 🍴 Fork the repository\n2. 🌿 Create your feature branch (`git checkout -b feature/amazing-feature`)\n3. 💾 Commit your changes (`git commit -m 'Add amazing feature'`)\n4. 📤 Push to the branch (`git push origin feature/amazing-feature`)\n5. 🎉 Open a Pull Request\n\nPlease feel free to:\n- 🐛 Report bugs\n- 💡 Suggest new features\n- 📖 Improve documentation\n- ⭐ Star the project if you find it useful!\n\n## 📄 License\n\nThis project is licensed under the **GNU General Public License v3.0** - see the [LICENSE](LICENSE) file for details.\n\n---\n\n\u003cdiv align=\"center\"\u003e\n\n**Made with ❤️ by [Yusef Mohamadi](https://github.com/yuseferi)**\n\nIf this project helped you, consider giving it a ⭐!\n\n[![GitHub stars](https://img.shields.io/github/stars/yuseferi/envyaml?style=social)](https://github.com/yuseferi/envyaml/stargazers)\n[![GitHub forks](https://img.shields.io/github/forks/yuseferi/envyaml?style=social)](https://github.com/yuseferi/envyaml/network/members)\n\n\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuseferi%2Fenvyaml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyuseferi%2Fenvyaml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuseferi%2Fenvyaml/lists"}