Env from file
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Kekskurse 2022-01-15 00:39:38 +01:00
parent 520ea1f3ca
commit be9ad98f58
Signed by: kekskurse
GPG Key ID: 728ACCB59341E7E4
1 changed files with 12 additions and 2 deletions

14
main.go
View File

@ -3,6 +3,7 @@ package main
import (
"database/sql"
"embed"
"errors"
"github.com/flamego/captcha"
"github.com/flamego/cors"
"github.com/flamego/flamego"
@ -94,10 +95,19 @@ func s3Connect() {
log.Debug().Msg("Finish create s3 client")
}
func loadEnvConfig() {
err := godotenv.Load()
if err != nil {
if _, err := os.Stat(".env"); err == nil {
err := godotenv.Load()
if err != nil {
log.Fatal().Err(err).Msg("Error loading .env file")
}
} else if errors.Is(err, os.ErrNotExist) {
log.Info().Msg("No .env file found")
} else {
log.Fatal().Err(err).Msg("Error load config from env")
}
}
func main() {