Files
turso/bindings/go
Pekka Enberg d115b414ad Merge 'Drop the beta warning' from Glauber Costa
0.7 ships next week, and Turso now runs in production at multiple
organizations — the top-of-page "this software is in BETA, use caution
with production data" warning no longer reflects reality, and it's the
first thing every visitor reads.
## What changed
- **About**: the ⚠️ BETA warning blockquote is gone. In its place, a
one-line status note: Turso runs in production today, with a pointer to
the FAQ for where the project stands on the way to 1.0.
- **FAQ "Is Turso Database ready for production use?"**: now opens with
"Yes" and the production users, followed by the testing story (DST,
Antithesis). The honest caveats stay, but softened: not yet 1.0, some
features explicitly experimental, and backups recommended as "the same
discipline you would apply to any database" rather than as a data-loss
threat.
- **New FAQ "How compatible is Turso Database with SQLite?"**: we're not
at 100% yet, COMPAT.md tracks the details, the gap is closing quickly,
and full compatibility is a requirement for 1.0.
- **libSQL FAQ**: still flatly said "libSQL is production ready, Turso
Database is not", contradicting the rest of the page. Now: both run in
production; libSQL is more battle-tested, Turso Database is where
development effort is focused.
The goal is to neither scare nor oversell: no data-loss warning up top,
but the README still says clearly that we are pre-1.0 and that some
SQLite differences remain.
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Reviewed-by: Mikaël Francoeur (@LeMikaelF)

Closes #7735
2026-07-12 08:52:00 +03:00
..
2025-12-23 15:34:43 +04:00
2025-12-10 22:41:11 +04:00
2025-12-10 18:23:44 +04:00
2025-12-10 18:23:44 +04:00
2025-12-16 16:39:28 +04:00
2026-04-25 14:55:19 -05:00
2026-04-25 14:55:19 -05:00
2025-12-10 18:23:44 +04:00
2026-07-03 10:56:57 -05:00
2025-12-10 18:23:44 +04:00

Turso Database for Go

Go Reference

Chat with other users of Turso on Discord


About

Turso Database runs in production today at multiple organizations. It has not yet reached 1.0, so as with any database we recommend keeping backups — see the FAQ for where the project stands.

Features

  • SQLite compatible: SQLite query language and file format support (status).
  • In-process: No network overhead, runs directly in your Go process
  • Cross-platform: Supports Linux, macOS, Windows
  • Remote partial sync: Bootstrap from a remote database, pull remote changes, and push local changes when online — all while enjoying a fully operational database offline.
  • No CGO: This driver uses the awesome purego library to call C (in this case Rust with C ABI) functions from Go.

Installation

go get turso.tech/database/tursogo

Get Started

package main

import (
	"database/sql"
	"fmt"
	"os"

	_ "turso.tech/database/tursogo"
)

func main() {
	conn, err := sql.Open("turso", ":memory:")
	if err != nil {
		fmt.Printf("Error: %v\n", err)
		os.Exit(1)
	}
	sql := "CREATE table go_turso (foo INTEGER, bar TEXT)"
	_, _ = conn.Exec(sql)

	sql = "INSERT INTO go_turso (foo, bar) values (?, ?)"
	stmt, _ := conn.Prepare(sql)
	defer stmt.Close()
	_, _ = stmt.Exec(42, "turso")
	rows, _ := conn.Query("SELECT * from go_turso")
	defer rows.Close()
	for rows.Next() {
		var a int
		var b string
		_ = rows.Scan(&a, &b)
		fmt.Printf("%d, %s\n", a, b) // 42, turso
	}
}

Sync Driver

Use a remote Turso database while working locally. You can bootstrap local state from the remote, pull remote changes, and push local commits.

Note: You need a Turso remote URL. See the Turso docs for provisioning and authentication.

package main

import (
	"context"
	"fmt"
	"log"
	"os"

	turso "turso.tech/database/tursogo"
)

func main() {
	ctx := context.Background()

	// Connect a local database to a remote Turso database
	db, err := turso.NewTursoSyncDb(ctx, turso.TursoSyncDbConfig{
		Path:      ":memory:", // local db path (or a file path)
		RemoteUrl: "https://<db>.<region>.turso.io",
		AuthToken: "<authToken>",
	})
	if err != nil {
		fmt.Printf("Error: %v\n", err)
		os.Exit(1)
	}

	conn, err := db.Connect(ctx)
	if err != nil {
		log.Fatal(err)
	}
	defer conn.Close()

	sql := "CREATE table go_turso (foo INTEGER, bar TEXT)"
	_, _ = conn.ExecContext(ctx, sql)

	sql = "INSERT INTO go_turso (foo, bar) values (?, ?)"
	stmt, _ := conn.PrepareContext(ctx, sql)
	defer stmt.Close()
	_, _ = stmt.ExecContext(ctx, 42, "turso")

	// Push local commits to remote
	_ = db.Push(ctx)

	// Pull new changes from remote into local
	_, _ = db.Pull(ctx)

	rows, _ := conn.QueryContext(ctx, "SELECT * from go_turso")
	defer rows.Close()
	for rows.Next() {
		var a int
		var b string
		_ = rows.Scan(&a, &b)
		fmt.Printf("%d, %s\n", a, b) // 42, turso
	}

	// Optional: inspect and manage sync state
	stats, err := db.Stats(ctx)
	if err != nil {
		log.Println("Stats unavailable:", err)
	} else {
		log.Println("Current revision:", stats.NetworkReceivedBytes)
	}

	_ = db.Checkpoint(ctx) // compact local WAL after many writes
}

License

This project is licensed under the MIT license.

Support