This repository contains small scripts as well as instructions to read .env files in several languages.
For using it in go first you have to have:
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)
}