Answers for "go dotenv"

Go
0

go dotenv

package util

import (
	"os"

	"github.com/joho/godotenv"
)

func GodotEnv(key string) string {
	env := make(chan string, 1)

	if os.Getenv("GO_ENV") != "production" {
		godotenv.Load(".env")
		env <- os.Getenv(key)
	} else {
		 env <- os.Getenv(key)
	}

	return <-env
}
Posted by: Guest on April-24-2021

Browse Popular Code Answers by Language