Skip to content

Commit

Permalink
Merge pull request go-gitea#1045 from tomcatzh/master
Browse files Browse the repository at this point in the history
Add mysql unix socket support.
  • Loading branch information
unknwon committed Mar 14, 2015
2 parents 08cd20b + 2bfe2dd commit 8238c28
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions models/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, ":")
Expand Down

0 comments on commit 8238c28

Please sign in to comment.