githubEdit

Go Generate

Integrate SOM code generation into your Go build process using go:generate.

Setup

Add a generate directive to a file in your project (commonly generate.go or in your model package):

//go:generate go run github.com/go-surreal/som@latest -i ./model

package main

Running Generation

Execute all generate directives in your project:

go generate ./...

Or run from a specific directory:

go generate ./model/...

Placement Options

In root directory

Create a generate.go file:

In model package

Add the directive to any .go file in your model directory:

CI/CD Integration

Add generation to your CI pipeline to verify generated code is up to date:

Custom Output Directory

Specify a custom output directory with -o:

Last updated