0
0
Fork 0
mirror of https://github.com/go-gitea/gitea synced 2024-11-22 01:32:25 +01:00

Merge pull request #1045 from tomcatzh/master

Add mysql unix socket support.
This commit is contained in:
无闻 2015-03-13 22:19:50 -04:00
commit 8238c28c31

View file

@ -89,8 +89,13 @@ func getEngine() (*xorm.Engine, error) {
cnnstr := ""
switch DbCfg.Type {
case "mysql":
cnnstr = fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8",
DbCfg.User, DbCfg.Passwd, DbCfg.Host, DbCfg.Name)
if DbCfg.Host[0] == '/' { // looks like a unix socket
cnnstr = fmt.Sprintf("%s:%s@unix(%s)/%s?charset=utf8",
DbCfg.User, DbCfg.Passwd, DbCfg.Host, DbCfg.Name)
} else {
cnnstr = fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8",
DbCfg.User, DbCfg.Passwd, DbCfg.Host, DbCfg.Name)
}
case "postgres":
var host, port = "127.0.0.1", "5432"
fields := strings.Split(DbCfg.Host, ":")