githubEdit

Installation

Prerequisites

  • Go 1.25 or later - SOM uses generics and iterators extensively

  • SurrealDB 3.x - Tested against version 3.0.0

Install SOM Generator

Use go run to always get the latest version:

go run github.com/go-surreal/som@latest -i <input_dir>

Option 2: Install Binary

Install globally for faster execution:

go install github.com/go-surreal/som@latest

Then run:

som -i <input_dir>

Option 3: Pin Version

For reproducible builds, pin to a specific version:

CLI Flags

The tool auto-detects the closest go.mod file and resolves paths relative to it. If --in is omitted, only static base files are generated (initialization mode).

Project Setup

1. Create Model Directory

2. Define Your First Model

Create model/user.go:

3. Generate Code

First, generate the static base files:

Then generate model-specific code:

4. Import Generated Code

The generated code is a self-contained Go module. Import it in your application:

SurrealDB Setup

Using Binary

Download from surrealdb.com/installarrow-up-right:

Using Docker Compose

Verify Installation

Test that everything works:

Next Steps

Last updated