You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: database/db.go
+5-1Lines changed: 5 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -19,6 +19,9 @@ var Db *gorm.DB
19
19
20
20
funcInitDb() *gorm.DB {
21
21
Db=connectDB()
22
+
ifDb==nil {
23
+
returnnil
24
+
}
22
25
23
26
err:=createRoot()
24
27
iferr!=nil {
@@ -37,7 +40,8 @@ func connectDB() *gorm.DB {
37
40
//load .env file
38
41
err:=godotenv.Load()
39
42
iferr!=nil {
40
-
fmt.Println(err)
43
+
fmt.Println(".env file was not found. You should add a .env file on project root with:\nDB_USERNAME \nDB_PASSWORD \nDB_NAME \nDB_HOST \nDB_PORT \nSECRET")
0 commit comments