{"id":34976413,"url":"https://github.com/pvormste/yetenv","last_synced_at":"2026-05-23T02:03:28.742Z","repository":{"id":52451823,"uuid":"234264873","full_name":"pvormste/yetenv","owner":"pvormste","description":"A small util package which helps to determine on which environment the application is running","archived":false,"fork":false,"pushed_at":"2021-04-28T22:10:44.000Z","size":70,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-28T12:44:32.055Z","etag":null,"topics":["environment","go","golang","library","package"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/pvormste/yetenv?tab=doc","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/pvormste.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":"2020-01-16T07:51:36.000Z","updated_at":"2020-04-20T11:45:27.000Z","dependencies_parsed_at":"2022-09-19T05:31:27.048Z","dependency_job_id":null,"html_url":"https://github.com/pvormste/yetenv","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/pvormste/yetenv","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pvormste%2Fyetenv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pvormste%2Fyetenv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pvormste%2Fyetenv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pvormste%2Fyetenv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pvormste","download_url":"https://codeload.github.com/pvormste/yetenv/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pvormste%2Fyetenv/sbom","scorecard":{"id":750610,"data":{"date":"2025-08-11","repo":{"name":"github.com/pvormste/yetenv","commit":"72126b666819b443c0a1683d508a90d6beed506d"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.4,"checks":[{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Code-Review","score":0,"reason":"Found 0/12 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/lint.yml:1","Warn: no topLevel permission defined: .github/workflows/tests.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/lint.yml:9: update your workflow using https://app.stepsecurity.io/secureworkflow/pvormste/yetenv/lint.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/tests.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/pvormste/yetenv/tests.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/tests.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/pvormste/yetenv/tests.yml/master?enable=pin","Info:   0 out of   3 GitHub-owned GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 5 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-22T20:14:31.578Z","repository_id":52451823,"created_at":"2025-08-22T20:14:31.578Z","updated_at":"2025-08-22T20:14:31.578Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33379721,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-23T01:21:08.577Z","status":"online","status_checked_at":"2026-05-23T02:00:05.530Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["environment","go","golang","library","package"],"created_at":"2025-12-27T00:13:44.438Z","updated_at":"2026-05-23T02:03:23.733Z","avatar_url":"https://github.com/pvormste.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![GoDoc](https://godoc.org/github.com/pvormste/yetenv?status.svg)](https://godoc.org/github.com/pvormste/yetenv) ![](https://github.com/pvormste/yetenv/workflows/lint/badge.svg?branch=master) ![](https://github.com/pvormste/yetenv/workflows/tests/badge.svg?branch=master)\n\n# yetenv\n\n`yetenv` is small util package which helps to detect on which environment the application is running and can\nload a configuration from a file into a configuration struct. \n\n## Install\n\n```bash\ngo get -u github.com/pvormste/yetenv\n```\n\n## Usage\n\n1. [Environment detection](https://github.com/pvormste/yetenv#environment-detection)\n2. [Config Loader](https://github.com/pvormste/yetenv#config-loader)\n\n### Environment detection\n\nEnvironment detection reads from a specific environment variable (Default: `ENVIRONMENT`). See examples below.\n\nThe `ENVIRONMENT` values are not case-sensitives.\n\n| `ENVIRONMENT` value | Constant |\n| ------------------- | -------- |\n| `production` | yetenv.Production |\n| `staging` | yetenv.Staging |\n| `test` | yetenv.Test |\n| any other value | yetenv.Develop |\n\n#### Using the defaults\n\nShell:\n```bash\n$ ENVIRONMENT=\"production\" go run main.go  # yetenv.Production\n$ ENVIRONMENT=\"staging\" go run main.go     # yetenv.Staging\n$ ENVIRONMENT=\"test\" go run main.go        # yetenv.Test\n$ ENVIRONMENT=\"local\" go run main.go       # yetenv.Develop\n```\n\nGo Code:\n```go\nenvironment := yetenv.GetEnvironment()\n\nswitch environment {\ncase yetenv.Production:\n    // Do something in production environment\ncase yetenv.Staging:\n    // Do something in staging environment\ncase yetenv.Test:\n    // Do something in test environment\ncase yetenv.Develop:\n    // Do something in develop environment\n}\n```\n\n#### Changing the default variable name\n\nShell:\n```bash\n$ APP_ENV=\"production\" go run main.go   # yetenv.Production\n$ APP_ENV=\"staging\" go run main.go      # yetenv.Staging\n$ APP_ENV=\"test\" go run main.go         # yetenv.Test\n$ APP_ENV=\"local\" go run main.go         # yetenv.Develop\n```\n\nGo Code:\n```go\nyetenv.DefaultVariableName = \"APP_ENV\"\nenvironment := yetenv.GetEnvironment()\n\nswitch environment {\ncase yetenv.Production:\n    // Do something in production environment\ncase yetenv.Staging:\n    // Do something in staging environment\ncase yetenv.Test:\n    // Do something in test environment\ncase yetenv.Develop:\n    // Do something in develop environment\n}\n```\n\n#### Reading temporary from a custom variable name\n\nShell:\n```bash\n$ APP_ENV=\"production\" go run main.go   # yetenv.Production\n$ APP_ENV=\"staging\" go run main.go      # yetenv.Staging\n$ APP_ENV=\"test\" go run main.go         # yetenv.Test\n$ APP_ENV=\"local\" go run main.go        # yetenv.Develop\n```\n\nGo Code:\n```go\nenvironment := yetenv.GetEnvironmentFromVariable(\"APP_ENV\")\n\nswitch environment {\ncase yetenv.Production:\n    // Do something in production environment\ncase yetenv.Staging:\n    // Do something in staging environment\ncase yetenv.Test:\n    // Do something in staging environment\ncase yetenv.Develop:\n    // Do something in develop environment\n}\n```\n\n### Config Loader\nThe config loader is able to load a configuration from one or more files into a configuration struct. To achieve this, \nit uses the [cleanenv package](https://github.com/ilyakaznacheev/cleanenv) under the hood - so please have a look into their\ndocumentation to get familar about the usage of configuration structs.\n\nIt also comes with a set of defaults, so it can be used with zero configuration out of the box. Nevertheless it is possible to\ncustomize the behavior of the ConfigLoader, so it doesn't get in your way.\n\n#### Default Load Behavior\nThe default load behavior works like this depending on the environment:\n - For `Develop`: Load from `./cfg.dev.env` and overwrite it by `./.env` and OS environment values.\n - For `Test`: Load from `./cfg.test.env` and overwrite it by `./.env` and OS environment values.\n - For `Staging`: Load from `./cfg.staging.env` and overwrite it by `./.env` and OS environment values.\n - For `Production`: Load from `./cfg.prod.env` and overwrite it by `./.env` and OS environment values.\n \n ```go\nc := Config{}\nerr := yetenv.NewConfigLoader().\n    UseDefaultLoadBehavior().\n    LoadInto(\u0026c)\n```\n\n##### Change load path\n - For `Develop`: Load from `./config/cfg.dev.env` and overwrite it by `./config/.env` and OS environment values.\n - For `Test`: Load from `./config/cfg.test.env` and overwrite it by `./config/.env` and OS environment values.\n - For `Staging`: Load from `./config/cfg.staging.env` and overwrite it by `./config/.env` and OS environment values.\n - For `Production`: Load from `./config/cfg.prod.env` and overwrite it by `./config/.env` and OS environment values.\n \n ```go\nc := Config{}\nerr := yetenv.NewConfigLoader().\n    UseLoadPath(\"./config\").\n    UseDefaultLoadBehavior().\n    LoadInto(\u0026c)\n```\n\n##### Change file processor\n - For `Develop`: Load from `./cfg.dev.yaml` and overwrite it by `./cfg.yaml` and OS environment values.\n - For `Test`: Load from `./cfg.test.yaml` and overwrite it by `./cfg.yaml` and OS environment values.\n - For `Staging`: Load from `./cfg.staging.yaml` and overwrite it by `./cfg.yaml` and OS environment values.\n - For `Production`: Load from `./cfg.prod.yaml` and overwrite it by `./cfg.yaml` and OS environment values.\n \n ```go\nc := Config{}\nerr := yetenv.NewConfigLoader().\n    UseFileProcessor(yetenv.YAML).\n    UseDefaultLoadBehavior().\n    LoadInto(\u0026c)\n```\n\n##### Change file name for a specific environment\nThe default load behavior works like this depending on the environment:\n - For `Develop`: Load from `./cfg.local.env` and overwrite it by `./.env` and OS environment values.\n - For `Test`: Load from `./cfg.testing.env` and overwrite it by `./.env` and OS environment values.\n - For `Staging`: Load from `./cfg.qa.env` and overwrite it by `./.env` and OS environment values.\n - For `Production`: Load from `./cfg.production.env` and overwrite it by `./.env` and OS environment values.\n \n ```go\nc := Config{}\nerr := yetenv.NewConfigLoader().\n    UseFileNameForEnvironment(yetenv.Develop, \"cfg.local\").\n    UseFileNameForEnvironment(yetenv.Test, \"cfg.testing\").\n    UseFileNameForEnvironment(yetenv.Staging, \"cfg.qa\").\n    UseFileNameForEnvironment(yetenv.Production, \"cfg.production\").\n    UseDefaultLoadBehavior().\n    LoadInto(\u0026c)\n```\n\n##### Inject environment\nBy default the ConfigLoader will use `yetenv.GetEnvironment()` to detect the current environment. If you customize the \nenvironment detection you can inject it this way:\n\n ```go\ncustomEnvironment := yetenv.Staging\nc := Config{}\nerr := yetenv.NewConfigLoader().\n    UseEnvironment(customEnvironment).\n    UseDefaultLoadBehavior().\n    LoadInto(\u0026c)\n```\n\n#### Custom Load Behavior\nThe custom load behavior is highly customizable - but keep in mind that some settings only applies when using specific\nsetting methods.\n\n| Setting | Applies When using | \n| ------- | ------------------ |\n| UseLoadPath() | `LoadFromFileForEnvironment()` |\n| UseFileProcessor() | `LoadFromFileForEnvironment()` |\n| UseFileNameForEnvironment() | `LoadFromFileForEnvironment()` |\n| UseEnvironment() | `LoadFromFileForEnvironment()` or `LoadFromConditionalFile()` |\n\n##### Example for a custom load behavior\n - For `Develop` and `Staging` and `Test`: Load from `./cfg.base.env` and overwrite by OS environment values.\n - For `Production`: Load from `./config/cfg.prod.yaml` and overwrite by OS environment values.\n - For `All Environments`: Load from `./other-config/cfg.toml` and  overwrite by OS environment values.\n\n ```go\ndevelopAndStagingCondition := func(configLoader *ConfigLoader, currentEnvironment Environment) bool {\n    return currentEnvironment == yetenv.Develop || currentEnvironment == yetenv.Staging || currentEnvironment == yetenv.Test\n}\n\ncustomEnvironment := yetenv.Staging\nc := Config{}\nerr := yetenv.NewConfigLoader().\n    UseLoadPath(\"./config\").\n    UseFileProcessor(yetenv.YAML).\n    UseEnvironment(customEnvironment).\n    UseCustomLoadBehavior().\n    LoadFromConditionalFile(\"./cfg.base.env\", developAndStagingCondition).\n    LoadFromFileForEnvironment(yetenv.Production).\n    LoadFromFile(\"./other-config/cfg.toml\").\n    LoadInto(\u0026c)\n```\n\nAs you can see: you can do very complicated things with it - I personally would recommend to keep it simple :-).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpvormste%2Fyetenv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpvormste%2Fyetenv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpvormste%2Fyetenv/lists"}