{"repo":"joho/godotenv","free":true,"listed":false,"github":"https://github.com/joho/godotenv","clone":"git clone https://github.com/joho/godotenv.git","description":"A Go port of Ruby's dotenv library (Loads environment variables from .env files)","language":"Go","stars":10592,"topics":["dotenv","environment-variables","go","golang"],"license":"MIT","category":"deployment-docker-iac","readme_excerpt":"GoDotEnv A Go (golang) port of the Ruby dotenv project (which loads env vars from a .env file). From the original Library: Storing configuration in the environment is one of the tenets of a twelve-factor app. Anything that is likely to change between deployment environments–such as resource handles for databases or credentials for external services–should be extracted from the code into environment variables. But it is not always practical to set environment variables on development machines or continuous integration servers where multiple projects are run. Dotenv load variables from a .env file into ENV when the environment is bootstrapped. It can be used as a library (for loading in env for your own daemons etc.) or as a bin command. There is test coverage and CI for both linuxish and Windows environments, but I make no guarantees about the bin version working on Windows. Installation As a library as a tool dependency: go = 1.24 or if you want to use it as a bin command Usage Add your application configuration to your .env file in the root of your project: Then in your Go app you can do something like If you're even lazier than that, you can just take advantage of the autoload package which will read in .env on import While .env in the project root is the default, you don't have to be constrained, both examples below are 100% legit If you want to be really fancy with your env file you can do comments and exports (below is a valid env file) Or finally you can do YAML(ish) st","default_branch":null,"files":null,"tree":[],"storefront":"/r/joho","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/joho/godotenv/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}