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 . // // 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 . // // 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 +}