From 2bfe2ddb6dcc9ed3e8e4ca7f04f1b86a3d106a6d Mon Sep 17 00:00:00 2001 From: Tomcat Date: Sat, 14 Mar 2015 02:21:47 +0800 Subject: [PATCH 1/2] Add mysql unix socket support. If the host setting looks like a unix socket (leading by char '/'), will use unix(host) as connection string --- models/models.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/models/models.go b/models/models.go index a9436fca85..b7986fed11 100644 --- a/models/models.go +++ b/models/models.go @@ -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, ":") From 27491031ba497dfd32313d0fa4b64bf6f917620c Mon Sep 17 00:00:00 2001 From: James Cracknell Date: Fri, 13 Mar 2015 21:20:08 -0600 Subject: [PATCH 2/2] Added .editorconfig --- .editorconfig | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000000..75ba9dacb5 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +# http://editorconfig.org + +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_style = tab + +[*.yml] +indent_style = space +indent_size = 2