Skip to content

Commit cf92a0c

Browse files
authored
Merge pull request #524 from jckimble/master
Add static_mock.go to allow building with CGO_ENABLED=0
2 parents a35b097 + 614d7c1 commit cf92a0c

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

sqlite3.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// +build cgo
2+
13
// Copyright (C) 2014 Yasuhiro Matsumoto <[email protected]>.
24
//
35
// Use of this source code is governed by an MIT-style

sqlite3_go18.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// +build cgo
2+
13
// Copyright (C) 2014 Yasuhiro Matsumoto <[email protected]>.
24
//
35
// Use of this source code is governed by an MIT-style

static_mock.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// +build !cgo
2+
3+
package sqlite3
4+
5+
import (
6+
"database/sql"
7+
"database/sql/driver"
8+
"errors"
9+
)
10+
11+
func init() {
12+
sql.Register("sqlite3", &SQLiteDriverMock{})
13+
}
14+
15+
type SQLiteDriverMock struct{}
16+
17+
var errorMsg = errors.New("Binary was compiled with 'CGO_ENABLED=0', go-sqlite3 requires cgo to work. This is a stub")
18+
19+
func (SQLiteDriverMock) Open(s string) (driver.Conn, error) {
20+
return nil, errorMsg
21+
}

0 commit comments

Comments
 (0)