mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-28 22:53:54 +03:00
Code clean up
This commit is contained in:
parent
5be881756b
commit
f59d2dd034
1 changed files with 1 additions and 9 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue