12345678910111213141516171819202122232425 |
- package models
- import (
- "fmt"
- "github.com/kptyun/KPTCOMM/pkg/setting"
- "github.com/kptyun/KPTCOMM/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), 200, 5, setting.DatabaseSetting.ShowXormlog); err != nil {
- log.Fatal(err.Error())
- fmt.Println("dbs 数据库初始化失败 ")
- }
- if err != nil {
- log.Fatalf("models.Setup err: %v", err)
- }
- }
|