-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmain.go
34 lines (26 loc) · 787 Bytes
/
main.go
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 (
"github.com/PacoDw/introduction_to_GORM/db"
"github.com/PacoDw/introduction_to_GORM/models"
"github.com/PacoDw/introduction_to_GORM/routes"
"github.com/gin-gonic/gin"
)
func init() {
// Get the database connection
db := db.GetConnection()
defer db.Close()
// Enable the log showing detailed log
db.LogMode(true)
// Migrate the Models to the database
// db.Debug().DropTableIfExists(&models.User{}) // drop db table
db.Debug().AutoMigrate(&models.User{})
}
func main() {
// Set the router as the default one shipped with Gin
router := gin.Default()
// Serve frontend static files
// router.Use(static.Serve("/", static.LocalFile("./views", true)))
// Setup route group for the user
routes.User(router.Group("/user"))
router.Run(":5000")
}