From 05afef726f09b2fc08d8b57dc41640eb713b1916 Mon Sep 17 00:00:00 2001 From: Theo Date: Wed, 27 Feb 2019 17:04:14 +0000 Subject: [PATCH] Add go-sql-driver imports to make it easier to run the examples --- README.md | 10 +++++++--- examples/basic/basic.go | 6 +++++- examples/blog/blog.go | 2 ++ examples/orders/orders.go | 1 + 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 183f015..89c482d 100644 --- a/README.md +++ b/README.md @@ -32,17 +32,21 @@ See **.travis.yml** for supported **go** versions. Different use case, is to functionally test with a real database - [go-txdb](https://github.com/DATA-DOG/go-txdb) all database related actions are isolated within a single transaction so the database can remain in the same state. -See implementation examples: + See implementation examples: - [blog API server](https://github.com/DATA-DOG/go-sqlmock/tree/master/examples/blog) - [the same orders example](https://github.com/DATA-DOG/go-sqlmock/tree/master/examples/orders) -### Something you may want to test +### Something you may want to test, assuming you use the [go-mysql-driver](https://github.com/go-sql-driver/mysql) ``` go package main -import "database/sql" +import ( + "database/sql" + + _ "github.com/go-sql-driver/mysql" +) func recordStats(db *sql.DB, userID, productID int64) (err error) { tx, err := db.Begin() diff --git a/examples/basic/basic.go b/examples/basic/basic.go index 0fbf98d..241380a 100644 --- a/examples/basic/basic.go +++ b/examples/basic/basic.go @@ -1,6 +1,10 @@ package main -import "database/sql" +import ( + "database/sql" + + _ "github.com/go-sql-driver/mysql" +) func recordStats(db *sql.DB, userID, productID int64) (err error) { tx, err := db.Begin() diff --git a/examples/blog/blog.go b/examples/blog/blog.go index c4aec06..6383f35 100644 --- a/examples/blog/blog.go +++ b/examples/blog/blog.go @@ -4,6 +4,8 @@ import ( "database/sql" "encoding/json" "net/http" + + _ "github.com/go-sql-driver/mysql" ) type api struct { diff --git a/examples/orders/orders.go b/examples/orders/orders.go index fb7e47e..06d616d 100644 --- a/examples/orders/orders.go +++ b/examples/orders/orders.go @@ -6,6 +6,7 @@ import ( "log" "github.com/kisielk/sqlstruct" + _ "github.com/go-sql-driver/mysql" ) const ORDER_PENDING = 0