{"id":17617500,"url":"https://github.com/gowizzard/dotenv","last_synced_at":"2025-03-30T00:41:27.539Z","repository":{"id":64717385,"uuid":"575755715","full_name":"gowizzard/dotenv","owner":"gowizzard","description":"An very lightweight library for dotenv files or for formatting already imported variables.","archived":false,"fork":false,"pushed_at":"2023-02-13T10:31:15.000Z","size":74,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-05T02:43:32.448Z","etag":null,"topics":["dotenv","environment","environment-variables","formatting","go","golang","golang-library","import"],"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/gowizzard.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","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-12-08T08:19:54.000Z","updated_at":"2023-01-31T21:47:22.000Z","dependencies_parsed_at":"2024-06-20T03:29:54.517Z","dependency_job_id":null,"html_url":"https://github.com/gowizzard/dotenv","commit_stats":{"total_commits":76,"total_committers":2,"mean_commits":38.0,"dds":"0.48684210526315785","last_synced_commit":"4604aacd41dc642827f966363e5855a113f751b3"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gowizzard%2Fdotenv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gowizzard%2Fdotenv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gowizzard%2Fdotenv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gowizzard%2Fdotenv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gowizzard","download_url":"https://codeload.github.com/gowizzard/dotenv/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246262492,"owners_count":20749170,"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":["dotenv","environment","environment-variables","formatting","go","golang","golang-library","import"],"created_at":"2024-10-22T19:14:12.923Z","updated_at":"2025-03-30T00:41:27.519Z","avatar_url":"https://github.com/gowizzard.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dotenv\n\n\u003cimg src=\"https://user-images.githubusercontent.com/30717818/206506472-340a3497-207f-45a9-9bb7-efb57c4274bc.svg\" alt=\".ENV\" width=\"150\" align=\"right\"\u003e\n\n[![GitHub go.mod Go version of a Go module](https://img.shields.io/github/go-mod/go-version/gowizzard/dotenv.svg)](https://golang.org/) [![Go](https://github.com/gowizzard/dotenv/actions/workflows/go.yml/badge.svg)](https://github.com/gowizzard/dotenv/actions/workflows/go.yml) [![CodeQL](https://github.com/gowizzard/dotenv/actions/workflows/codeql.yml/badge.svg)](https://github.com/gowizzard/dotenv/actions/workflows/codeql.yml) [![CompVer](https://github.com/gowizzard/dotenv/actions/workflows/compver.yml/badge.svg)](https://github.com/gowizzard/dotenv/actions/workflows/compver.yml) [![Go Reference](https://pkg.go.dev/badge/github.com/gowizzard/dotenv/v2.svg)](https://pkg.go.dev/github.com/gowizzard/dotenv/v2) [![Go Report Card](https://goreportcard.com/badge/github.com/gowizzard/dotenv/v2)](https://goreportcard.com/report/github.com/gowizzard/dotenv/v2) [![GitHub issues](https://img.shields.io/github/issues/gowizzard/dotenv)](https://github.com/gowizzard/dotenv/issues) [![GitHub forks](https://img.shields.io/github/forks/gowizzard/dotenv)](https://github.com/gowizzard/dotenv/network) [![GitHub stars](https://img.shields.io/github/stars/gowizzard/dotenv)](https://github.com/gowizzard/dotenv/stargazers) [![GitHub license](https://img.shields.io/github/license/gowizzard/dotenv)](https://github.com/gowizzard/dotenv/blob/master/LICENSE)\n\nWith this lightweight library you can read a local file with environment variables into your project. Additionally, you can use functions to read the data and the variable will be returned directly in the desired type.\n\n## Installation\n\nFirst you have to install the package. You can do this as follows:\n\n```shell\ngo get github.com/gowizzard/dotenv/v2\n```\n\n## How to use\n\n## Import variables\n\nIf you want to read your local `.env` file, so you can use these variables in your project, you can use this function for that.\n\nWith this function the data will be loaded from the file and set as local variables. After that you can read them with standard functions, or you can use the following functions.\n\n[Here](https://regex101.com/r/SEDjKj/10) you can find the regex expression which is used to read the environment variables.\n\n```go\nerr := dotenv.Import(\".env\")\nif err != nil {\n    panic(err)\n}\n```\n\n## Read variables\n\nIf you don't want to work with the standard golang function `func Getenv(key string) string` from the `package os` or `func Getenv(key string) (value string, found bool)` from `package syscall`, because you want to output the variables directly in a certain type, then you can use the following different functions.\n\nThe functions check directly if the desired variable is available and returns the value. If the value is not available, then the default value of the type is returned.\n\nYou can also use these functions without the import function if the variables are already available locally.\n\n### Boolean\n\nWith this function you can read an environment variable and return it directly as `type bool`.\n\n```go\nresult := dotenv.Boolean(\"KEY\")\nprintln(result)\n```\n\n### Float\n\nWith this function you can read an environment variable and return it directly as `type float64`. In this function you must not only specify the desired key, but also the bit size of the float type. The bit size can be between `0 to 64`.\n\n```go\nresult := dotenv.Float(\"KEY\", 64)\nprintln(result)\n```\n\n### Integer\n\nWith this function you can read an environment variable and return it directly as `type int64`. In this function, the base and the bit size must be specified in addition to the key. The base must contain one of the following values `0, 2 to 36` and the bit size can be between `0 to 64`. \n\n```go\nresult := dotenv.Integer(\"KEY\", 10, 64)\nprintln(result)\n```\n\n### String\n\nWith this function you can read an environment variable and return it directly as `type string`.\n\n```go\nresult := dotenv.String(\"KEY\")\nprintln(result)\n```\n\n## Special thanks\n\nThanks to [JetBrains](https://github.com/JetBrains) for supporting me with this and other [open source projects](https://www.jetbrains.com/community/opensource/#support).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgowizzard%2Fdotenv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgowizzard%2Fdotenv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgowizzard%2Fdotenv/lists"}