{"id":23946153,"url":"https://github.com/ermos/dotenv","last_synced_at":"2026-06-11T22:31:28.941Z","repository":{"id":57563102,"uuid":"316956121","full_name":"ermos/dotenv","owner":"ermos","description":"Go package for working with env file easily","archived":false,"fork":false,"pushed_at":"2026-02-19T14:05:54.000Z","size":50,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-19T17:36:11.889Z","etag":null,"topics":["dotenv","dotenv-parser","go","go-package","golang"],"latest_commit_sha":null,"homepage":"https://github.com/ermos/dotenv","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/ermos.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2020-11-29T13:22:34.000Z","updated_at":"2026-02-19T14:06:10.000Z","dependencies_parsed_at":"2024-05-02T11:05:02.092Z","dependency_job_id":"dd1ed3b6-f861-4ee7-a983-0bfcad4fea54","html_url":"https://github.com/ermos/dotenv","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/ermos/dotenv","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ermos%2Fdotenv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ermos%2Fdotenv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ermos%2Fdotenv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ermos%2Fdotenv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ermos","download_url":"https://codeload.github.com/ermos/dotenv/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ermos%2Fdotenv/sbom","scorecard":{"id":381538,"data":{"date":"2025-08-11","repo":{"name":"github.com/ermos/dotenv","commit":"ac4831a5a00c6db00d3d16f4a6b97cc21b985813"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.3,"checks":[{"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":"Code-Review","score":0,"reason":"Found 0/6 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":"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":"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":"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":"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/go-codeql-analysis.yml:31: update your workflow using https://app.stepsecurity.io/secureworkflow/ermos/dotenv/go-codeql-analysis.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go-codeql-analysis.yml:35: update your workflow using https://app.stepsecurity.io/secureworkflow/ermos/dotenv/go-codeql-analysis.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go-codeql-analysis.yml:43: update your workflow using https://app.stepsecurity.io/secureworkflow/ermos/dotenv/go-codeql-analysis.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go-codeql-analysis.yml:57: update your workflow using https://app.stepsecurity.io/secureworkflow/ermos/dotenv/go-codeql-analysis.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go-govuln-check.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/ermos/dotenv/go-govuln-check.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go-govuln-check.yml:30: update your workflow using https://app.stepsecurity.io/secureworkflow/ermos/dotenv/go-govuln-check.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go-lint-check.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/ermos/dotenv/go-lint-check.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go-lint-check.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/ermos/dotenv/go-lint-check.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/go-lint-check.yml:26: update your workflow using https://app.stepsecurity.io/secureworkflow/ermos/dotenv/go-lint-check.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go-test.yml:9: update your workflow using https://app.stepsecurity.io/secureworkflow/ermos/dotenv/go-test.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go-test.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/ermos/dotenv/go-test.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/go-test.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/ermos/dotenv/go-test.yml/main?enable=pin","Warn: goCommand not pinned by hash: .github/workflows/go-govuln-check.yml:35","Info:   0 out of  10 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   2 third-party GitHubAction dependencies pinned","Info:   0 out of   1 goCommand 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":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/go-codeql-analysis.yml:1","Warn: no topLevel permission defined: .github/workflows/go-govuln-check.yml:1","Info: topLevel 'contents' permission set to 'read': .github/workflows/go-lint-check.yml:11","Warn: no topLevel permission defined: .github/workflows/go-test.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":"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":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"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":7,"reason":"SAST tool detected but not run on all commits","details":["Info: SAST configuration detected: CodeQL","Warn: 0 commits out of 2 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-18T15:33:41.935Z","repository_id":57563102,"created_at":"2025-08-18T15:33:41.935Z","updated_at":"2025-08-18T15:33:41.935Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34221150,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-11T02:00:06.485Z","response_time":57,"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":["dotenv","dotenv-parser","go","go-package","golang"],"created_at":"2025-01-06T08:28:43.953Z","updated_at":"2026-06-11T22:31:28.935Z","avatar_url":"https://github.com/ermos.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DotEnv\n\n\u003e Loads environment variables from .env file with Go\n\n## Installation\n\n```bash\ngo get github.com/ermos/dotenv\n```\n\n## Quick Start\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"log\"\n    \"os\"\n\n    \"github.com/ermos/dotenv\"\n)\n\nfunc main() {\n    if err := dotenv.Parse(\".env\"); err != nil {\n        log.Fatal(err)\n    }\n\n    fmt.Println(os.Getenv(\"DATABASE_URL\"))\n}\n```\n\n## .env File Syntax\n\nThis parser follows the [dotenv](https://github.com/bkeepers/dotenv) conventions and supports most features from popular implementations ([Node.js dotenv](https://github.com/motdotla/dotenv), [Python python-dotenv](https://github.com/theskumar/python-dotenv)).\n\n### Basic Syntax\n\n```bash\n# Simple key-value\nKEY=value\n\n# Comments (lines starting with #)\n# This is a comment\nKEY=value  # Inline comments are supported\n```\n\n### Quoted Values\n\n```bash\n# Double quotes (escape sequences supported)\nMESSAGE=\"Hello\\nWorld\"\n\n# Single quotes (literal, no escape processing)\nPATH='/usr/local/bin'\n\n# Quotes preserve spaces\nGREETING=\"Hello, World!\"\n```\n\n### Export Prefix\n\nCompatible with shell scripts - the `export` keyword is stripped:\n\n```bash\nexport DATABASE_URL=postgres://localhost/mydb\nexport API_KEY=\"secret\"\n```\n\n\u003e Reference: [POSIX Shell Command Language](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html)\n\n### Variable Substitution\n\n```bash\n# Braced syntax (recommended)\nBASE_URL=https://api.example.com\nAPI_ENDPOINT=${BASE_URL}/v1/users\n\n# Simple syntax (POSIX-style)\nHOME_DIR=/home/user\nCONFIG=$HOME_DIR/.config\n\n# Note: $VAR_NAME matches the longest valid identifier\n# Use ${VAR}_suffix to delimit variable names\nPREFIX=${APP}_production\n```\n\n\u003e Reference: [POSIX Parameter Expansion](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_02)\n\n### Default Values\n\n```bash\n# Use default if variable is unset OR empty\nDATABASE_HOST=${DB_HOST:-localhost}\nDATABASE_PORT=${DB_PORT:-5432}\n\n# Use default only if variable is unset (keeps empty values)\nOPTIONAL=${MAYBE_EMPTY-default}\n\n# Nested defaults\nCONFIG_PATH=${CUSTOM_PATH:-${HOME:-/tmp}/config}\n```\n\n| Syntax | Behavior |\n|--------|----------|\n| `${VAR:-default}` | Use `default` if `VAR` is **unset or empty** |\n| `${VAR-default}` | Use `default` only if `VAR` is **unset** |\n\n\u003e Reference: [Bash Parameter Expansion](https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html)\n\n### Multiline Values\n\n```bash\n# Quoted multiline (quotes span multiple lines)\nPRIVATE_KEY=\"-----BEGIN RSA PRIVATE KEY-----\nMIIEpAIBAAKCAQEA...\n-----END RSA PRIVATE KEY-----\"\n\n# JSON configuration\nCONFIG='{\n  \"host\": \"localhost\",\n  \"port\": 8080\n}'\n\n# Backslash line continuation\nLONG_COMMAND=docker run \\\n  --name myapp \\\n  --env-file .env \\\n  myimage:latest\n```\n\n### Escape Sequences (in double quotes)\n\n| Sequence | Result |\n|----------|--------|\n| `\\n` | Newline |\n| `\\t` | Tab |\n| `\\r` | Carriage return |\n| `\\\\` | Backslash |\n| `\\\"` | Double quote |\n\n```bash\nMESSAGE=\"Line 1\\nLine 2\\tTabbed\"\nPATH=\"C:\\\\Users\\\\name\"\nQUOTED=\"He said \\\"Hello\\\"\"\n```\n\n### Syntax Summary\n\n| Feature | Example | Supported |\n|---------|---------|-----------|\n| Basic assignment | `KEY=value` | Yes |\n| Comments | `# comment` | Yes |\n| Inline comments | `KEY=value # comment` | Yes |\n| Double quotes | `KEY=\"value\"` | Yes |\n| Single quotes | `KEY='value'` | Yes |\n| Export prefix | `export KEY=value` | Yes |\n| Variable substitution | `${VAR}` or `$VAR` | Yes |\n| Default values | `${VAR:-default}` | Yes |\n| Multiline (quoted) | `KEY=\"line1\\nline2\"` | Yes |\n| Backslash continuation | `KEY=a\\`\u003cbr\u003e`b` | Yes |\n\n## API Reference\n\n### Parse\n\nParses a `.env` file and sets environment variables.\n\n```go\nerr := dotenv.Parse(\".env\")\nerr := dotenv.Parse(\"/path/to/custom.env\")\n```\n\n### Require\n\nValidates that required environment variables are set.\n\n```go\nerr := dotenv.Require(\"DATABASE_URL\", \"API_KEY\", \"SECRET\")\nif err != nil {\n    log.Fatal(err) // \"the following environment variables are required: API_KEY, SECRET\"\n}\n```\n\n### LoadStruct\n\nLoads environment variables into a struct using tags.\n\n```go\ntype Config struct {\n    Host     string `env:\"HOST\" default:\"localhost\"`\n    Port     int    `env:\"PORT\" default:\"8080\"`\n    Debug    bool   `env:\"DEBUG\"`\n    APIKey   string `env:\"API_KEY\" required:\"true\"`\n}\n\nvar cfg Config\nif err := dotenv.LoadStruct(\u0026cfg); err != nil {\n    log.Fatal(err)\n}\n```\n\n#### Struct Tags\n\n| Tag | Description |\n|-----|-------------|\n| `env:\"VAR_NAME\"` | Maps field to environment variable |\n| `default:\"value\"` | Default value if not set |\n| `required:\"true\"` | Error if variable is not set |\n| `validator:\"name\"` | Custom validator (with `LoadStructWithOptions`) |\n\n#### Supported Types\n\n`string`, `int`, `int8`, `int16`, `int32`, `int64`, `uint`, `uint8`, `uint16`, `uint32`, `uint64`, `float32`, `float64`, `bool`\n\n#### Custom Validators\n\n```go\nopts := dotenv.LoadOptions{\n    Validators: map[string]dotenv.Validator{\n        \"email\": func(v reflect.Value) error {\n            if !strings.Contains(v.String(), \"@\") {\n                return fmt.Errorf(\"invalid email format\")\n            }\n            return nil\n        },\n    },\n}\n\ntype Config struct {\n    Email string `env:\"EMAIL\" validator:\"email\"`\n}\n\nvar cfg Config\nerr := dotenv.LoadStructWithOptions(\u0026cfg, opts)\n```\n\n### Typed Getters\n\nHelper functions to retrieve and convert environment variables.\n\n```go\n// Basic getters (return zero value on error)\ndotenv.GetString(\"KEY\")\ndotenv.GetInt(\"PORT\")\ndotenv.GetBool(\"DEBUG\")\ndotenv.GetFloat64(\"RATE\")\ndotenv.GetFloat32(\"RATIO\")\ndotenv.GetInt64(\"BIG_NUMBER\")\ndotenv.GetUint(\"COUNT\")\n\n// With default values\ndotenv.GetStringOrDefault(\"KEY\", \"default\")\ndotenv.GetIntOrDefault(\"PORT\", 8080)\ndotenv.GetBoolOrDefault(\"DEBUG\", false)\ndotenv.GetFloat64OrDefault(\"RATE\", 1.0)\ndotenv.GetFloat32OrDefault(\"RATIO\", 0.5)\ndotenv.GetInt64OrDefault(\"BIG_NUMBER\", 0)\ndotenv.GetUintOrDefault(\"COUNT\", 1)\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fermos%2Fdotenv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fermos%2Fdotenv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fermos%2Fdotenv/lists"}