diff options
author | Unknwon <u@gogs.io> | 2016-08-12 02:56:50 -0700 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2016-08-12 02:56:50 -0700 |
commit | 5be881756b093534462493520eb8f0600235407c (patch) | |
tree | 17ce1707561d69f780d0e79cdc494e4f456827bf /models/models.go | |
parent | 42964272149e2b8f5f3959100c43210cd508e2f5 (diff) | |
download | gitea-5be881756b093534462493520eb8f0600235407c.tar.gz gitea-5be881756b093534462493520eb8f0600235407c.zip |
#3442 add test suites
Diffstat (limited to 'models/models.go')
-rw-r--r-- | models/models.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/models/models.go b/models/models.go index ac69a778e7..f9ce67d935 100644 --- a/models/models.go +++ b/models/models.go @@ -97,6 +97,21 @@ func LoadConfigs() { DbCfg.Path = sec.Key("PATH").MustString("data/gogs.db") } +// parsePostgreSQLHostPort parses given input in various forms defined in +// https://www.postgresql.org/docs/current/static/libpq-connect.html#LIBPQ-CONNSTRING +// and returns proper host and port number. +func parsePostgreSQLHostPort(info string) (string, string) { + host, port := "127.0.0.1", "5432" + if strings.Contains(info, ":") && !strings.HasSuffix(info, "]") { + idx := strings.LastIndex(info, ":") + host = info[:idx] + port = info[idx+1:] + } else if len(info) > 0 { + host = info + } + return host, port +} + func getEngine() (*xorm.Engine, error) { connStr := "" var Param string = "?" |