From 3f18cd5ebf529636d36ab426c3dfa23234e23482 Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Thu, 26 Dec 2019 19:40:02 +0900 Subject: [PATCH 1/2] Create a `mysql.Connect` API. --- driver.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/driver.go b/driver.go index c1bdf1199..3b61625ca 100644 --- a/driver.go +++ b/driver.go @@ -105,3 +105,15 @@ func (d MySQLDriver) OpenConnector(dsn string) (driver.Connector, error) { cfg: cfg, }, nil } + +// Connect connects to MySQL server. +// You can use this function to create custom connector which dynamically +// change the config. The cfg object must not be changed during calling +// this function. +func Connect(ctx context.Context, cfg *Config) (driver.Conn, error) { + connector, err := NewConnector(cfg) + if err != nil { + return nil, err + } + return connector.Connect(ctx) +} From 423604e691168b09e598598c2fbc600cc1729d4a Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Sun, 29 Dec 2019 15:31:58 +0900 Subject: [PATCH 2/2] Update driver.go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Márk Sági-Kazár --- driver.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/driver.go b/driver.go index 3b61625ca..62828d378 100644 --- a/driver.go +++ b/driver.go @@ -108,7 +108,7 @@ func (d MySQLDriver) OpenConnector(dsn string) (driver.Connector, error) { // Connect connects to MySQL server. // You can use this function to create custom connector which dynamically -// change the config. The cfg object must not be changed during calling +// change the config. The cfg object must not be changed during calling // this function. func Connect(ctx context.Context, cfg *Config) (driver.Conn, error) { connector, err := NewConnector(cfg)