23 lines
333 B
Go
23 lines
333 B
Go
package variable
|
|
|
|
import (
|
|
"log"
|
|
"os"
|
|
|
|
"github.com/joho/godotenv"
|
|
)
|
|
|
|
// use godot package to load/read the .env file and
|
|
// return the value of the key
|
|
func GetEnvVariable(key string) string {
|
|
|
|
// load .env file
|
|
err := godotenv.Load(".env")
|
|
|
|
if err != nil {
|
|
log.Fatalf("Error loading .env file")
|
|
}
|
|
|
|
return os.Getenv(key)
|
|
}
|