From f59d2dd0343880fff7cdbbee7305eae27829c8de Mon Sep 17 00:00:00 2001 From: Unknwon Date: Fri, 12 Aug 2016 03:04:50 -0700 Subject: [PATCH] Code clean up --- models/models.go | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/models/models.go b/models/models.go index f9ce67d93..98e07c50f 100644 --- a/models/models.go +++ b/models/models.go @@ -128,15 +128,7 @@ func getEngine() (*xorm.Engine, error) { DbCfg.User, DbCfg.Passwd, DbCfg.Host, DbCfg.Name, Param) } case "postgres": - host, port := "127.0.0.1", "5432" - if strings.Contains(DbCfg.Host, ":") && !strings.HasSuffix(DbCfg.Host, "]") { - idx := strings.LastIndex(DbCfg.Host, ":") - host = DbCfg.Host[:idx] - port = DbCfg.Host[idx+1:] - } else if len(DbCfg.Host) > 0 { - host = DbCfg.Host - } - + host, port := parsePostgreSQLHostPort(DbCfg.Host) if host[0] == '/' { // looks like a unix socket connStr = fmt.Sprintf("postgres://%s:%s@:%s/%s%ssslmode=%s&host=%s", url.QueryEscape(DbCfg.User), url.QueryEscape(DbCfg.Passwd), port, DbCfg.Name, Param, DbCfg.SSLMode, host)