diff options
author | Unknwon <u@gogs.io> | 2016-08-12 03:04:50 -0700 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2016-08-12 03:04:50 -0700 |
commit | f59d2dd0343880fff7cdbbee7305eae27829c8de (patch) | |
tree | bc0c1ebcc60199edeec127c50dcc4d3177fb5bc6 | |
parent | 5be881756b093534462493520eb8f0600235407c (diff) | |
download | gitea-f59d2dd0343880fff7cdbbee7305eae27829c8de.tar.gz gitea-f59d2dd0343880fff7cdbbee7305eae27829c8de.zip |
Code clean up
-rw-r--r-- | models/models.go | 10 |
1 files changed, 1 insertions, 9 deletions
diff --git a/models/models.go b/models/models.go index f9ce67d935..98e07c50f4 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) |