Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of Changes
Architecture decisions
reflectpackage is not available in WASM. Thestdb-gentool (https://gitlab.com/digitalxero/stdb-gen) reads//stdb:directives and generates all serialization, table accessors, and module definitions at compile time.//go:wasmexport— Requires Go 1.24+. Exports are inserver/runtime/exports.gobehind//go:build wasip1.recover()in the WASM call reducer wrapper.Summary
This PR adds first-class Go language support to SpacetimeDB, including a complete server-side WASM module SDK, a WebSocket client SDK, Rust-side codegen for Go bindings, CLI build toolchain integration, project templates, and a comprehensive test suite covering all 66 integration tests.
Highlights
sdks/go/server/) — Write SpacetimeDB modules in Go, compiled to WASM viaGOOS=wasip1 GOARCH=wasmwith//go:wasmexport(Go 1.24+). Supports tables, reducers, procedures, views, event tables, scheduled reducers, lifecycle hooks, row-level security, and HTTP from procedures.sdks/go/client/) — Channel-based WebSocket client with BSATN protocol v2, brotli compression, client-side table cache (xsync lock-free maps), subscriptions, and reducer callbacks.sdks/go/bsatn/) — Complete binary serialization matching the SpacetimeDB wire format (LE integers, u32-prefixed strings/arrays, u8 sum tags, sequential product fields).//stdb:directives. Generates type-safe table accessors, BSATN serialization, index methods, and module definition.crates/codegen/src/go.rs) — Implements theLangtrait for generating Go client bindings from module schemas.crates/cli/src/tasks/go.rs) —spacetime buildandspacetime initsupport for Go modules.crates/core/src/host/wasmtime/wasi_stubs.rs) — Minimal WASI Preview 1 shims (fd_write for stdout/stderr, clock, args, environ) to support Go's wasip1 runtime.basic-goandchat-console-gostarter projects forspacetime init.Templates (
templates/)basic-go/— Minimal starter with a Person table and add/say_hello reducerschat-console-go/— Chat app with User/Message tables, connect/disconnect lifecycle, and a terminal clientAPI and ABI breaking changes
None
Expected complexity level and risk
2 - does require go knowlage, but it fully integrates with the existing integration tests and benchmarks
This should be relatively isolated from existing code, except for the updates to the cli to add go language support.
Rust changes (
crates/) — 18 files, ~1,900 linescrates/codegen/src/go.rs(1,133 lines) — Go client binding codegen implementingLangtraitcrates/cli/src/tasks/go.rs(123 lines) — Go module build task (stdb-gen → go generate → go build)crates/cli/src/subcommands/init.rs— Go template support forspacetime initcrates/cli/src/subcommands/generate.rs— Go language option forspacetime generatecrates/core/src/host/wasmtime/wasi_stubs.rs(272 lines) — WASI Preview 1 stubs for Go WASM modulescrates/testing/— Go module build support in test harnesscrates/smoketests/— Go module smoke testTesting
cargo test -p spacetimedb-sdk -- go::)cargo test -p spacetimedb-sdk -- go_procedures::)cargo test -p spacetimedb-sdk -- go_view::)cargo test -p spacetimedb-sdk -- go_event_table_tests::)cd sdks/go && go test ./...)sdks/gowithsdks/go/v#.#.#so that go clients/servers will be able to properly import the code.Test modules (
modules/) — 46 files, ~4,500 linessdk-test-go/sdk-testmodulesdk-test-connect-disconnect-go/sdk-test-procedure-go/sdk-test-view-go/sdk-test-event-table-go/benchmarks-go/module-test-go/perf-test-go/Benchmark Results: Rust vs Go
Circles Benchmark (Debug mode)
IA Loop Benchmark (Debug mode)
Index Scans (Release mode, 1.2M rows)
{id}(unique PK){chunk}(btree){x, z, dimension}(3-col btree){x, z}(2-col prefix)Key Takeaways