Skip to content

Commit 05afef7

Browse files
author
Theo
committed
Add go-sql-driver imports to make it easier to run the examples
1 parent 7f7699b commit 05afef7

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,21 @@ See **.travis.yml** for supported **go** versions.
3232
Different use case, is to functionally test with a real database - [go-txdb](https://github.com/DATA-DOG/go-txdb)
3333
all database related actions are isolated within a single transaction so the database can remain in the same state.
3434

35-
See implementation examples:
35+
See implementation examples:
3636

3737
- [blog API server](https://github.com/DATA-DOG/go-sqlmock/tree/master/examples/blog)
3838
- [the same orders example](https://github.com/DATA-DOG/go-sqlmock/tree/master/examples/orders)
3939

40-
### Something you may want to test
40+
### Something you may want to test, assuming you use the [go-mysql-driver](https://github.com/go-sql-driver/mysql)
4141

4242
``` go
4343
package main
4444

45-
import "database/sql"
45+
import (
46+
"database/sql"
47+
48+
_ "github.com/go-sql-driver/mysql"
49+
)
4650

4751
func recordStats(db *sql.DB, userID, productID int64) (err error) {
4852
tx, err := db.Begin()

examples/basic/basic.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package main
22

3-
import "database/sql"
3+
import (
4+
"database/sql"
5+
6+
_ "github.com/go-sql-driver/mysql"
7+
)
48

59
func recordStats(db *sql.DB, userID, productID int64) (err error) {
610
tx, err := db.Begin()

examples/blog/blog.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"database/sql"
55
"encoding/json"
66
"net/http"
7+
8+
_ "github.com/go-sql-driver/mysql"
79
)
810

911
type api struct {

examples/orders/orders.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"log"
77

88
"github.com/kisielk/sqlstruct"
9+
_ "github.com/go-sql-driver/mysql"
910
)
1011

1112
const ORDER_PENDING = 0

0 commit comments

Comments
 (0)