NAPPDesafio/api/helpers/variable/variable.go
2024-07-21 00:15:14 -03:00

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)
}