From 100cd181bcc9fc46981cc2a4b88c05ad459fbc8f Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 1 May 2014 18:53:41 -0400 Subject: Add router log config option --- models/models.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'models') diff --git a/models/models.go b/models/models.go index 8e8835ab51..059435f15f 100644 --- a/models/models.go +++ b/models/models.go @@ -58,10 +58,10 @@ func NewTestEngine(x *xorm.Engine) (err error) { case "postgres": var host, port = "127.0.0.1", "5432" fields := strings.Split(DbCfg.Host, ":") - if len(fields) > 0 { + if len(fields) > 0 && len(strings.TrimSpace(fields[0])) > 0 { host = fields[0] } - if len(fields) > 1 { + if len(fields) > 1 && len(strings.TrimSpace(fields[1])) > 0 { port = fields[1] } cnnstr := fmt.Sprintf("user=%s password=%s host=%s port=%s dbname=%s sslmode=%s", @@ -91,10 +91,10 @@ func SetEngine() (err error) { case "postgres": var host, port = "127.0.0.1", "5432" fields := strings.Split(DbCfg.Host, ":") - if len(fields) > 0 { + if len(fields) > 0 && len(strings.TrimSpace(fields[0])) > 0 { host = fields[0] } - if len(fields) > 1 { + if len(fields) > 1 && len(strings.TrimSpace(fields[1])) > 0 { port = fields[1] } orm, err = xorm.NewEngine("postgres", fmt.Sprintf("user=%s password=%s host=%s port=%s dbname=%s sslmode=%s", -- cgit v1.2.3