package models import ( "fmt" "../pkg/setting" "../routers/restful" "log" ) func Setup() { var err error // restful 接口的 数据库初始化 if err := restful.SQLInit("mysql", fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8&parseTime=True&loc=Local", setting.DatabaseSetting.User, setting.DatabaseSetting.Password, setting.DatabaseSetting.Host, setting.DatabaseSetting.Name), 1000, 10,setting.DatabaseSetting.ShowXormlog); err != nil { log.Fatal(err.Error()) fmt.Println("dbs 数据库初始化失败 ") } if err != nil { log.Fatalf("models.Setup err: %v", err) } }