Skip to content

Go

Go SDK

The SurrealDB SDK for Go lets you connect to SurrealDB from servers, command-line tools, APIs and other Go programs. It connects to a remote instance over WebSocket or HTTP and sends SurrealQL as CBOR.

Queries and record operations are generic functions, such as surrealdb.Query[T] and surrealdb.Select[T]. Each one decodes the result into the Go type that you give.

Use the SDK to run queries, read and write records, and sign users in. You can also keep their tokens fresh, receive changes with live queries, and group statements in interactive transactions.

Important

The SDK requires Go 1.24 or later. It is available as a Go module, and its module path is github.com/surrealdb/surrealdb.go/v2.

Note

The latest version of the SDK is v2.0.1. It works with SurrealDB 3.3 and later 3.x releases, and with SurrealDB 4.x. The current SurrealDB release is v4.0.1.

Before you upgrade a project from version 1 of the SDK, read Migrating to Go SDK 2.x. Version 2 changes the module path, the supported server versions, and how the SDK sends some Go values to the server.

To contribute to the SDK code, submit an Issue or Pull Request in the surrealdb.go repository. To contribute to this documentation, submit an Issue or Pull Request in the docs.surrealdb.com repository.

Was this page helpful?

Last updated