1aad5b395eabd767425a836d165db594597d7e05.svn-base 594 B

1234567891011121314151617181920212223242526
  1. package models
  2. import (
  3. "fmt"
  4. "../pkg/setting"
  5. "../routers/restful"
  6. "log"
  7. )
  8. func Setup() {
  9. var err error
  10. // restful 接口的 数据库初始化
  11. if err := restful.SQLInit("mysql", fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8&parseTime=True&loc=Local",
  12. setting.DatabaseSetting.User,
  13. setting.DatabaseSetting.Password,
  14. setting.DatabaseSetting.Host,
  15. setting.DatabaseSetting.Name), 1000, 10,setting.DatabaseSetting.ShowXormlog); err != nil {
  16. log.Fatal(err.Error())
  17. fmt.Println("dbs 数据库初始化失败 ")
  18. }
  19. if err != nil {
  20. log.Fatalf("models.Setup err: %v", err)
  21. }
  22. }