aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormattn <mattn.jp@gmail.com>2018-02-02 21:40:21 +0900
committerGitHub <noreply@github.com>2018-02-02 21:40:21 +0900
commitcf92a0c6c881ae9db15f8720a7be6439c24b4b7c (patch)
tree5cadb7a5ede1c8e938b62b2370de0fd5299e3a81
parentMerge pull request #521 from mattn/fix520 (diff)
parentAdd static_mock.go to allow building with CGO_ENABLED=0 (diff)
downloadgolite-cf92a0c6c881ae9db15f8720a7be6439c24b4b7c.tar.gz
golite-cf92a0c6c881ae9db15f8720a7be6439c24b4b7c.tar.xz
Merge pull request #524 from jckimble/master
Add static_mock.go to allow building with CGO_ENABLED=0
-rw-r--r--sqlite3.go2
-rw-r--r--sqlite3_go18.go2
-rw-r--r--static_mock.go21
3 files changed, 25 insertions, 0 deletions
diff --git a/sqlite3.go b/sqlite3.go
index 739f91d..a081893 100644
--- a/sqlite3.go
+++ b/sqlite3.go
@@ -1,3 +1,5 @@
+// +build cgo
+
// Copyright (C) 2014 Yasuhiro Matsumoto <mattn.jp@gmail.com>.
//
// Use of this source code is governed by an MIT-style
diff --git a/sqlite3_go18.go b/sqlite3_go18.go
index f9e08e1..dd0f5a7 100644
--- a/sqlite3_go18.go
+++ b/sqlite3_go18.go
@@ -1,3 +1,5 @@
+// +build cgo
+
// Copyright (C) 2014 Yasuhiro Matsumoto <mattn.jp@gmail.com>.
//
// Use of this source code is governed by an MIT-style
diff --git a/static_mock.go b/static_mock.go
new file mode 100644
index 0000000..48629d1
--- /dev/null
+++ b/static_mock.go
@@ -0,0 +1,21 @@
+// +build !cgo
+
+package sqlite3
+
+import (
+ "database/sql"
+ "database/sql/driver"
+ "errors"
+)
+
+func init() {
+ sql.Register("sqlite3", &SQLiteDriverMock{})
+}
+
+type SQLiteDriverMock struct{}
+
+var errorMsg = errors.New("Binary was compiled with 'CGO_ENABLED=0', go-sqlite3 requires cgo to work. This is a stub")
+
+func (SQLiteDriverMock) Open(s string) (driver.Conn, error) {
+ return nil, errorMsg
+}