read-dotenv-files

This repository contains small scripts as well as instructions to read .env files in several languages.

View the Project on GitHub Baelfire18/read-dotenv-files

Go Dotenv

For using it in go first you have to have:

  1. A Go version installed.

  2. Installed the go-dotenv package.

For a .env file like this:

package main
import (
 "fmt"
 "os"
 "github.com/joho/godotenv"
)
 
func main() {
 godotenv.Load("../.env")
 
 DB_NAME := os.Getenv("DB_NAME")
 fmt.Println(DB_NAME)
}