Add custom mysql database port.

This commit is contained in:
topjohncian 2020-04-07 19:50:23 +08:00
parent 816b537787
commit ced609c995
2 changed files with 3 additions and 1 deletions

View file

@ -32,10 +32,11 @@ func Init() {
// 未指定数据库时使用SQLite
db, err = gorm.Open("sqlite3", util.RelativePath(conf.DatabaseConfig.DBFile))
} else {
db, err = gorm.Open(conf.DatabaseConfig.Type, fmt.Sprintf("%s:%s@(%s)/%s?charset=utf8&parseTime=True&loc=Local",
db, err = gorm.Open(conf.DatabaseConfig.Type, fmt.Sprintf("%s:%s@(%s:%s)/%s?charset=utf8&parseTime=True&loc=Local",
conf.DatabaseConfig.User,
conf.DatabaseConfig.Password,
conf.DatabaseConfig.Host,
conf.DatabaseConfig.Port,
conf.DatabaseConfig.Name))
}
}

View file

@ -15,6 +15,7 @@ type database struct {
Name string
TablePrefix string
DBFile string
Port string
}
// system 系统通用配置