File tree 2 files changed +11
-7
lines changed
2 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -21,9 +21,11 @@ type MongoInstance struct {
21
21
var MI MongoInstance
22
22
23
23
func ConnectDB () {
24
- err := godotenv .Load ()
25
- if err != nil {
26
- log .Fatal ("Error loading .env file" )
24
+ if os .Getenv ("APP_ENV" ) != "production" {
25
+ err := godotenv .Load ()
26
+ if err != nil {
27
+ log .Fatal ("Error loading .env file" )
28
+ }
27
29
}
28
30
29
31
client , err := mongo .NewClient (options .Client ().ApplyURI (os .Getenv ("MONGO_URI" )))
Original file line number Diff line number Diff line change @@ -19,9 +19,11 @@ func setupRoutes(app *fiber.App) {
19
19
}
20
20
21
21
func main () {
22
- err := godotenv .Load ()
23
- if err != nil {
24
- log .Fatal ("Error loading .env file" )
22
+ if os .Getenv ("APP_ENV" ) != "production" {
23
+ err := godotenv .Load ()
24
+ if err != nil {
25
+ log .Fatal ("Error loading .env file" )
26
+ }
25
27
}
26
28
27
29
app := fiber .New ()
@@ -34,7 +36,7 @@ func main() {
34
36
setupRoutes (app )
35
37
36
38
port := os .Getenv ("PORT" )
37
- err = app .Listen (":" + port )
39
+ err : = app .Listen (":" + port )
38
40
39
41
if err != nil {
40
42
log .Fatal ("Error app failed to start" )
You can’t perform that action at this time.
0 commit comments