talira

godotenv

Loads environment variables from .env files in Go

open sourceMITfree

godotenv is a Go port of Ruby's dotenv: it loads environment variables from a .env file into the process environment, so configuration such as credentials and resource handles stays out of the code, twelve-factor style. Call godotenv.Load() at startup (or load specific files, or read them into a map without touching the environment), or use the godotenv command to run another program with a .env file's variables set. It's MIT-licensed and has CI on Linux and Windows.

Problems it solves

  • load settings from a .env file in my Go app during local development
  • keep secrets like API keys out of my Go code and in environment variables
  • run a command with the variables from a .env file set

Features

  • load .env files into the environment with godotenv.Load()
  • load several named files, or read them into a map
  • godotenv command to run a program with a .env file's variables
  • MIT licence

Alternatives

The same job

These do what godotenv does.

  1. Viper Configuration for Go applications from files, environment variables, flags and remote stores

Compare godotenv with the top 3