Add driverName to be possible change driver name

move-code
Yasuhiro Matsumoto 2022-01-09 22:38:53 +09:00 committed by mattn
parent 98c52198ca
commit c0fa5ea6d6
1 changed files with 8 additions and 1 deletions

View File

@ -4,6 +4,7 @@
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.
//go:build cgo
// +build cgo
package sqlite3
@ -233,8 +234,14 @@ const (
columnTimestamp string = "timestamp"
)
// This variable can be replaced with -ldflags like below:
// go build -ldflags="-X 'github.com/mattn/go-sqlite3.driverName=my-sqlite3'"
var driverName = "sqlite3"
func init() {
sql.Register("sqlite3", &SQLiteDriver{})
if driverName != "" {
sql.Register(driverName, &SQLiteDriver{})
}
}
// Version returns SQLite library version information.