From 7b1a07fa97e8107bccb3d60f2b6cb086554c9f62 Mon Sep 17 00:00:00 2001 From: mattes Date: Fri, 17 Oct 2014 11:34:43 -0700 Subject: [PATCH] mysql scheme fix --- driver/mysql/mysql.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/driver/mysql/mysql.go b/driver/mysql/mysql.go index 9ae8dc9..81bc7a4 100644 --- a/driver/mysql/mysql.go +++ b/driver/mysql/mysql.go @@ -22,7 +22,12 @@ type Driver struct { const tableName = "schema_migrations" func (driver *Driver) Initialize(url string) error { - db, err := sql.Open("mysql", strings.TrimLeft(url, "mysql://")) + urlWithoutScheme := strings.SplitN(url, "mysql://", 2) + if len(urlWithoutScheme) != 2 { + return errors.New("invalid mysql:// scheme") + } + + db, err := sql.Open("mysql", urlWithoutScheme[1]) if err != nil { return err }