1 changed files with 18 additions and 0 deletions
@ -0,0 +1,18 @@
@@ -0,0 +1,18 @@
|
||||
package config |
||||
|
||||
import ( |
||||
"github.com/joho/godotenv" |
||||
"os" |
||||
) |
||||
|
||||
func GetEnvVar(key string) string { |
||||
if os.Getenv("ENVIRONMENT") == "DEV" { |
||||
err := godotenv.Load() |
||||
if err != nil { |
||||
// we're going to panic because without the env variables, our app couldn't run anyways
|
||||
panic("Error loading environment variable") |
||||
} |
||||
} |
||||
|
||||
return os.Getenv(key) |
||||
} |
||||
Loading…
Reference in new issue