godotenv icon indicating copy to clipboard operation
godotenv copied to clipboard

Add suport to env setted

Open afranioce opened this issue 7 years ago • 4 comments

afranioce avatar Mar 09 '18 12:03 afranioce

The change looks good, has tests, seems like it would work.

I'm not too keen on merging it without understanding the purpose. Is this an implementation of #38? If so, is it reasonably complete?

joho avatar Mar 13 '18 21:03 joho

I have a dynamic environment variable set outside the dotenv and replacing this variable would be interesting.

example:

# .env
SSL_CERT_FILE=${API_PATH}/config/cert/${API_HOST}.pem
SSL_KEY_FILE=${API_PATH}/config/cert/${API_HOST}.key
// Get base path application
_, filename, _, _ := runtime.Caller(0)
os.Setenv("API_PATH", path.Dir(filename)+"/..")

var err error
if currentEnvironment, ok := os.LookupEnv("ENV"); ok == true {
	err = godotenv.Load(os.ExpandEnv("$API_PATH/.env." + currentEnvironment))
} else {
	err = godotenv.Load(os.ExpandEnv("$API_PATH/.env"))
}

afranioce avatar Mar 14 '18 00:03 afranioce

Implement of #17

afranioce avatar Mar 14 '18 00:03 afranioce

Hi, what is the problem with this PR? Do you need any help?

arsoba avatar Feb 25 '19 12:02 arsoba