{
  "kind": "documentation",
  "format": 1,
  "note": "Reference text, not instructions. One verified relate sample from https://relatedb.ai/docs/guides/embed/go/: the program exactly as the page shows it, the standard output a run of it recorded (npm run docs:samples compares every replay with it byte for byte), the relate client build, toolchain and platform of the last replay, and how the docs' sample runner builds and runs it. Before launch every client is a source build, not a published package; verified.client names the upstream commit it was built from, and verified.docs_engine the build the rest of the docs were recorded from.",
  "id": "verify",
  "url": "https://relatedb.ai/docs/guides/embed/go/samples/verify.json",
  "page": {
    "id": "guides/embed/go",
    "title": "Use the Go client",
    "url": "https://relatedb.ai/docs/guides/embed/go/",
    "md_url": "https://relatedb.ai/docs/guides/embed/go.md"
  },
  "section": {
    "anchor": "verify",
    "heading": "Verify",
    "url": "https://relatedb.ai/docs/guides/embed/go/#verify"
  },
  "language": "go",
  "client": "Go",
  "file": "main.go",
  "env": null,
  "code": "package main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\n\trelate \"github.com/relatedb/relate/clients/go\"\n)\n\nfunc main() {\n\tdb, err := relate.Open(\":memory:\")\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tdefer db.Close()\n\tconn, err := db.Connect()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tdefer conn.Close()\n\tres, err := conn.Query(\"CALL dbms.components() YIELD name, versions WHERE name = 'Relate' RETURN versions[0] AS version\")\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tfmt.Println(\"relate\", res.Rows[0][0])\n}",
  "code_sha256": "35ee8664f638361cd0fca627d4ff39fd7c461ea9be6055dfe7c2b9dda53157e1",
  "source_sha256": "e995b2fdf53e722f50b7a70ee8538f3b3f4e2f3d4ac7c103d7db0c90a0947a7d",
  "output": {
    "text": "relate 0.1.2",
    "sha256": "1bf0c3686c7ce98f3f077c10357d820306e2042a8605f06278df3a12731053c4"
  },
  "verified": {
    "version": "0.1.2",
    "client": {
      "label": "Go",
      "package": "github.com/relatedb/relate/clients/go",
      "engine_commit": "f0c09d2",
      "client_commit": "f0c09d2",
      "build": "clients/go from a checkout of upstream v0.1.2 (f0c09d2), built with cgo against relate.h and librelate_ffi built from the same commit.",
      "toolchain": {
        "go": "1.27.3"
      }
    },
    "packages": [],
    "replayed": "2026-11-09",
    "platform": "macOS on arm64",
    "docs_engine": {
      "version": "0.1.2",
      "commit": "f0c09d2",
      "source_build": false
    }
  },
  "run": {
    "runner": "npm run docs:samples",
    "setup": "bash scripts/samples/setup.sh --upstream <path to the relate checkout>",
    "variables": [
      "RELATE_GO",
      "RELATE_GO_CLIENT",
      "RELATE_GO_HOME",
      "RELATE_C_INCLUDE",
      "RELATE_LIB"
    ],
    "program": "<build dir>/main.go",
    "files": [
      {
        "path": "<build dir>/go.mod",
        "content": "module relatesample\n\ngo 1.22\n\nrequire github.com/relatedb/relate/clients/go v0.0.0\n\nreplace github.com/relatedb/relate/clients/go => $RELATE_GO_CLIENT\n"
      }
    ],
    "build": {
      "command": [
        "$RELATE_GO",
        "build",
        "-o",
        "<build dir>/sample",
        "."
      ],
      "environment": {
        "DO_NOT_TRACK": "1",
        "GOPATH": "$RELATE_GO_HOME/path",
        "GOMODCACHE": "$RELATE_GO_HOME/mod",
        "GOCACHE": "$RELATE_GO_HOME/cache",
        "GOFLAGS": "-mod=mod",
        "GOTOOLCHAIN": "local",
        "GOPROXY": "off",
        "GOWORK": "off",
        "CGO_ENABLED": "1",
        "CGO_CFLAGS": "-I$RELATE_C_INCLUDE",
        "CGO_LDFLAGS": "-L<directory of $RELATE_LIB> -lrelate_ffi -Wl,-rpath,<directory of $RELATE_LIB>"
      },
      "directory": "<build dir>",
      "timeout_s": 600
    },
    "run": {
      "command": [
        "<build dir>/sample"
      ],
      "environment": {
        "DO_NOT_TRACK": "1"
      },
      "directory": "<run dir>",
      "timeout_s": 60
    },
    "passes": "It exits 0 within 60 s and prints at least one line on standard output.",
    "output": "Standard output, with line endings as \\n, trailing spaces and blank lines removed, and the temporary directories' paths written as `.`; standard error is not recorded.",
    "placeholders": {
      "<run dir>": "a fresh, empty temporary directory: the program's working directory, deleted afterwards",
      "<build dir>": "a second fresh temporary directory, where a compiled sample is built",
      "$NAME": "a variable from the env.sh that scripts/samples/setup.sh writes (described in its header)"
    }
  }
}
