From 671e666c2e88052a814eeaed6bc8506ef326eb63 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Sun, 9 Jan 2022 22:39:48 +0900 Subject: [PATCH] Add example using driverName --- _example/custom_driver_name/Makefile | 12 ++++++++++++ _example/custom_driver_name/main.go | 13 +++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 _example/custom_driver_name/Makefile create mode 100644 _example/custom_driver_name/main.go 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) + } +}