diff --git a/main.go b/main.go index 110a879..914a88b 100644 --- a/main.go +++ b/main.go @@ -44,8 +44,10 @@ func main() { } // Auto Migrate - db.AutoMigrate(&User{}, &Location{}, &Record{}, &Token{}) - + err = db.AutoMigrate(&User{}, &Location{}, &Record{}, &Token{}) + if err != nil { + panic("failed to AutoMigrate database") + } r := gin.Default() // 用户注册接口 @@ -287,9 +289,9 @@ func main() { var record Record record.UserID = tokenData.UserID - if err != nil { - // Handle the error if the conversion fails - } + // if err != nil { + // // Handle the error if the conversion fails + // } record.LocationID = uint(request.LocationID) record.Date = request.Date record.Time = request.Time @@ -389,7 +391,10 @@ func main() { c.JSON(200, gin.H{"code": 0, "message": "查询成功", "data": location}) }) - r.Run() + err = r.Run() + if err != nil { + panic("failed at r.Run()") + } } func generateToken(userID uint) string {