From 77cb67b44ea7327a6823da7bc222be16107c1f17 Mon Sep 17 00:00:00 2001 From: Matt Holt Date: Thu, 6 Jul 2023 23:22:59 -0600 Subject: [PATCH] Add Go to readme --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index 069f022..f6a65b7 100644 --- a/README.md +++ b/README.md @@ -226,6 +226,20 @@ With [Datasette](https://datasette.io/), you should prefer the [`datasette-sqlit datasette data.db --load-extension ./ulid0 ``` +For Go programs using the [`mattn/go-sqlite3` package](https://pkg.go.dev/github.com/mattn/go-sqlite3), you can load the extension like so: + +```go +func init() { + sql.Register("sqlite3-ulid", &sqlite3.SQLiteDriver{ + ConnectHook: func(conn *sqlite3.SQLiteConn) error { + return conn.LoadExtension("./ulid0.so", "sqlite3_ulid_init") + }, + }) +} +``` + +Then instead of using the "sqlite3" driver when opening your DB, use "sqlite3-ulid". + ## Supporting I (Alex 👋🏼) spent a lot of time and energy on this project and [many other open source projects](https://github.com/asg017?tab=repositories&q=&type=&language=&sort=stargazers). If your company or organization uses this library (or you're feeling generous), then please [consider supporting my work](https://alexgarcia.ulid/work.html), or share this project with a friend!