summaryrefslogtreecommitdiff
path: root/internal/storage/sqlite_nocgo.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/storage/sqlite_nocgo.go')
-rw-r--r--internal/storage/sqlite_nocgo.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/internal/storage/sqlite_nocgo.go b/internal/storage/sqlite_nocgo.go
new file mode 100644
index 0000000..9862440
--- /dev/null
+++ b/internal/storage/sqlite_nocgo.go
@@ -0,0 +1,21 @@
+//go:build !cgo
+
+package storage
+
+import (
+ "database/sql"
+ "database/sql/driver"
+
+ modernc "modernc.org/sqlite"
+)
+
+// Register the modernc pure-Go SQLite driver under the "sqlite3" name so that
+// the rest of the codebase can use sql.Open("sqlite3", ...) regardless of
+// whether CGO is enabled.
+func init() {
+ sql.Register("sqlite3", &modernc.Driver{})
+}
+
+// modernc.Driver satisfies driver.Driver; this blank-import ensures the
+// compiler sees the interface is satisfied.
+var _ driver.Driver = (*modernc.Driver)(nil)