aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYasuhiro Matsumoto <mattn.jp@gmail.com>2022-01-09 22:39:48 +0900
committermattn <mattn.jp@gmail.com>2022-01-10 23:30:33 +0900
commit671e666c2e88052a814eeaed6bc8506ef326eb63 (patch)
tree1d9ec88a5b8e00ac771a4d0c734840ee6b87338d
parentAdd driverName to be possible change driver name (diff)
downloadgolite-671e666c2e88052a814eeaed6bc8506ef326eb63.tar.gz
golite-671e666c2e88052a814eeaed6bc8506ef326eb63.tar.xz
Add example using driverName
-rw-r--r--_example/custom_driver_name/Makefile12
-rw-r--r--_example/custom_driver_name/main.go13
2 files changed, 25 insertions, 0 deletions
diff --git a/_example/custom_driver_name/Makefile b/_example/custom_driver_name/Makefile
new file mode 100644
index 0000000..91fcde6
--- /dev/null
+++ b/_example/custom_driver_name/Makefile
@@ -0,0 +1,12 @@
+TARGET = custom_driver_name
+ifeq ($(OS),Windows_NT)
+TARGET := $(TARGET).exe
+endif
+
+all : $(TARGET)
+
+$(TARGET) : main.go
+ go build -ldflags="-X 'github.com/mattn/go-sqlite3.driverName=my-sqlite3'"
+
+clean :
+ rm -f $(TARGET)
diff --git a/_example/custom_driver_name/main.go b/_example/custom_driver_name/main.go
new file mode 100644
index 0000000..3148cae
--- /dev/null
+++ b/_example/custom_driver_name/main.go
@@ -0,0 +1,13 @@
+package main
+
+import (
+ "database/sql"
+
+ _ "github.com/mattn/go-sqlite3"
+)
+
+func main() {
+ for _, driver := range sql.Drivers() {
+ println(driver)
+ }
+}