-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
34 lines (28 loc) · 728 Bytes
/
main.go
File metadata and controls
34 lines (28 loc) · 728 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package main
import (
"context"
"log"
"github.com/gin-gonic/gin"
"github.com/glauberratti/MyFirstGoCRUD/src/configuration/database/mongodb"
"github.com/glauberratti/MyFirstGoCRUD/src/controller/routes"
"github.com/joho/godotenv"
)
func main() {
err := godotenv.Load()
if err != nil {
log.Fatal("Error loading .env file")
return
}
database, err := mongodb.NewMongoDBConnection(context.Background())
if err != nil {
log.Fatalf("Error trying to connect to database, error=%s \n", err.Error())
return
}
userController := initDependencies(database)
router := gin.Default()
routes.InitRoutes(&router.RouterGroup, userController)
if err := router.Run(":5000"); err != nil {
log.Fatal(err)
return
}
}