-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.go
63 lines (58 loc) · 1.3 KB
/
server.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package main
import (
//"github.com/gin-gonic/gin"
//"github.com/jinzhu/gorm"
_ "github.com/go-sql-driver/mysql"
"log"
//"time"
//"gintest/models"
"gintest/services"
)
//func initDB() gorm.DB {
// db, err := gorm.Open("mysql", "root:@/temp?charset=utf8&parseTime=True")
// if err != nil {
// println("Error opening mysql connection")
// }
// db.DB()
//
// db.DB().Ping()
// db.DB().SetMaxIdleConns(10)
// db.DB().SetMaxOpenConns(100)
//
// db.SingularTable(true)
//
// db.AutoMigrate(&models.VehicleMake{}, &models.VehicleModel{})
//
// return db
//}
func checkErr(err error, msg string) {
if err != nil {
log.Fatalln(msg, err)
}
}
func main() {
// db := initDB()
// defer db.DB().Close()
//
// router := gin.Default()
// router.GET("/", func(c *gin.Context) {
//// newMake := models.NewMake("Mercedes")
//// models.CreateMake(&newMake, &db)
//// newModel := models.NewModel("E-300", "2011", &newMake)
//// models.CreateModel(&newModel, &db)
// make := models.SearchMakeById(1, &db)
// if make != nil {
// println(make.Name)
// }
// c.String(200, "Hello World")
// })
//
// router.GET("/user/:name", func(c *gin.Context) {
// name := c.Params.ByName("name")
// message := "Hello " + name
// c.String(200, message)
// })
// router.Run(":8080")
svc := services.VehicleService{}
svc.Run()
}