Skip to content

Independent open source · Apache-2.0

FoundationDB,
from Go.

A pure-Go FoundationDB client, a Go port of Apple's Record Layer, and an embedded SQL engine.

The client does not require cgo or libfdb_c. The SQL engine runs in the application process, so FoundationDB is the only server to operate.

Get started Source on GitHub go get fdb.dev/pkg/fdbgo/fdb@master
Application process
database/sqlSQL engineParser · planner · executor
Protobuf recordsRecord LayerRecords · indexes · cursors
Key-value transactionsPure-Go FDB clientFoundationDB wire protocol
TCP
FoundationDB clusterSeparate server · 7.3 protocol

Each layer is usable as an API. The Record Layer and SQL engine can also run on Apple's C client with the libfdbc build tag and cgo.

APIs

Pure-Go FDB client

Key-value transactions with reads, writes, range reads, and retries on retryable errors. The API is modeled on Apple's Go binding.

pkg/fdbgo/fdb

Record Layer

A Go port of Apple's Record Layer. Stores protobuf records with secondary indexes, schema metadata, and resumable scans.

pkg/recordlayer

SQL engine

A database/sql driver over the Record Layer. Queries are planned and executed in the application process. It is not a PostgreSQL-compatible server.

pkg/relational/sqldriver

Examples

Transact runs the function in a transaction and runs it again after a retryable error. Keep external side effects outside the function.

The repository includes complete Record Layer and SQL programs with setup and error handling.

Key-value transactionfdb.dev/pkg/fdbgo/fdb
value, err := db.Transact(
    func(tx fdb.WritableTransaction) (any, error) {
        tx.Set(fdb.Key("greeting"), []byte("hello"))
        return tx.Get(fdb.Key("greeting")).Get()
    },
)
if err != nil {
    return err
}
fmt.Println(string(value.([]byte)))

Client connection setup →

SQL queryfdb.dev/pkg/relational/sqldriver
rows, err := sqlDB.QueryContext(ctx,
    `SELECT id, email FROM users
     WHERE status = ? ORDER BY id LIMIT 10`,
    "active",
)
if err != nil {
    return err
}
defer rows.Close()

Complete SQL program →

Compatibility testing

Each suite compares specific cases with an external reference implementation. A passing suite does not establish compatibility outside the tested cases.

Client behavior

Differential tests run the Go client and libfdb_c against the same FoundationDB cluster and compare the results.

Client differential tests

Record-store data

Conformance tests exercise Go and Java reads and writes on shared stores. The Java reference is Record Layer 4.14.2.0.

Java conformance suite

SQL results and plans

Cross-engine scenarios and regression tests compare query behavior with the Java relational layer.

SQL conformance scenarios
Mixing Go and Java writers

Collation, TEXT Unicode behavior, Go-only vector layouts, and engine-private SQL continuation tokens have documented exceptions. Existing Go SQL storage may require an explicit migration.

Earlier Go-vs-libfdb_c speedup and write-parity claims were withdrawn. Benchmark results apply only to the measured configurations. Benchmarks → · Correction and methodology →

Resources

The docs cover the development branch (v0.2.0 candidate).

Build and run locally

An unofficial, independent project. Not affiliated with, sponsored by, or endorsed by Apple Inc. or the FoundationDB project.