Merge branch 'main' of github.com:ardeman/project-legalgo-go
This commit is contained in:
commit
c23ee933c1
@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
"os"
|
||||||
|
|
||||||
"legalgo-BE-go/config"
|
"legalgo-BE-go/config"
|
||||||
"legalgo-BE-go/database"
|
"legalgo-BE-go/database"
|
||||||
@ -12,8 +13,14 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
if err := godotenv.Load(); err != nil {
|
// Check if the .env file exists
|
||||||
log.Fatal("cannot load environment file")
|
if _, err := os.Stat(".env"); err == nil {
|
||||||
|
// Load environment variables from .env file if it exists
|
||||||
|
if err := godotenv.Load(); err != nil {
|
||||||
|
log.Println("Error loading .env file, continuing without it")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.Println(".env file not found, skipping load")
|
||||||
}
|
}
|
||||||
|
|
||||||
config.InitEnv()
|
config.InitEnv()
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
"os"
|
||||||
|
|
||||||
"legalgo-BE-go/config"
|
"legalgo-BE-go/config"
|
||||||
"legalgo-BE-go/database"
|
"legalgo-BE-go/database"
|
||||||
@ -18,8 +19,14 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
if err := godotenv.Load(); err != nil {
|
// Check if the .env file exists
|
||||||
log.Fatal("cannot load environment file")
|
if _, err := os.Stat(".env"); err == nil {
|
||||||
|
// Load environment variables from .env file if it exists
|
||||||
|
if err := godotenv.Load(); err != nil {
|
||||||
|
log.Println("Error loading .env file, continuing without it")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.Println(".env file not found, skipping load")
|
||||||
}
|
}
|
||||||
|
|
||||||
config.InitEnv()
|
config.InitEnv()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user