diff options
author | Yasuhiro Matsumoto <mattn.jp@gmail.com> | 2022-01-09 22:39:48 +0900 |
---|---|---|
committer | mattn <mattn.jp@gmail.com> | 2022-01-10 23:30:33 +0900 |
commit | 671e666c2e88052a814eeaed6bc8506ef326eb63 (patch) | |
tree | 1d9ec88a5b8e00ac771a4d0c734840ee6b87338d | |
parent | Add driverName to be possible change driver name (diff) | |
download | golite-671e666c2e88052a814eeaed6bc8506ef326eb63.tar.gz golite-671e666c2e88052a814eeaed6bc8506ef326eb63.tar.xz |
Add example using driverName
-rw-r--r-- | _example/custom_driver_name/Makefile | 12 | ||||
-rw-r--r-- | _example/custom_driver_name/main.go | 13 |
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) + } +} |