From 32fdd30cc71c05e5a1d4a116f11b7288092bf6ca Mon Sep 17 00:00:00 2001 From: Craig Childs Date: Wed, 8 Aug 2018 07:36:06 +0100 Subject: [PATCH] Update mysql connection string & add missing port config option --- msq/connection.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/msq/connection.go b/msq/connection.go index 65faab8..645b53b 100644 --- a/msq/connection.go +++ b/msq/connection.go @@ -3,6 +3,7 @@ package msq import ( "errors" "fmt" + "strconv" "github.com/jinzhu/gorm" _ "github.com/jinzhu/gorm/dialects/mysql" @@ -12,6 +13,7 @@ import ( type ConnectionConfig struct { Type string Host string + Port int Username string Password string Database string @@ -73,10 +75,11 @@ func (c *Connection) getConnectionString() string { if dbType == "mysql" { return fmt.Sprintf( - "%s:%s@%s/%s?charset=%s&parseTime=True&loc=%s", + "%s:%s@tcp(%s:%s)/%s?charset=%s&parseTime=True&loc=%s", c.Config.Username, c.Config.Password, c.Config.Host, + strconv.Itoa(c.Config.Port), c.Config.Database, c.Config.Charset, c.Config.Locale,