Skip to content

Commit c0fa5ea

Browse files
committed
Add driverName to be possible change driver name
1 parent 98c5219 commit c0fa5ea

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

sqlite3.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// Use of this source code is governed by an MIT-style
55
// license that can be found in the LICENSE file.
66

7+
//go:build cgo
78
// +build cgo
89

910
package sqlite3
@@ -233,8 +234,14 @@ const (
233234
columnTimestamp string = "timestamp"
234235
)
235236

237+
// This variable can be replaced with -ldflags like below:
238+
// go build -ldflags="-X 'github.com/mattn/go-sqlite3.driverName=my-sqlite3'"
239+
var driverName = "sqlite3"
240+
236241
func init() {
237-
sql.Register("sqlite3", &SQLiteDriver{})
242+
if driverName != "" {
243+
sql.Register(driverName, &SQLiteDriver{})
244+
}
238245
}
239246

240247
// Version returns SQLite library version information.

0 commit comments

Comments
 (0)