{
  "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": "metadata",
  "url": "https://relatedb.ai/docs/guides/embed/go/samples/metadata.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": "read-result-metadata",
    "heading": "Read result metadata",
    "url": "https://relatedb.ai/docs/guides/embed/go/#read-result-metadata"
  },
  "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\nconst team = `\nCREATE (ada:Person {name: 'Ada', role: 'engineer'}),\n       (grace:Person {name: 'Grace', role: 'engineer'}),\n       (noor:Person {name: 'Noor', role: 'maintainer'}),\n       (relate:Project {name: 'relate', language: 'Rust'}),\n       (tck:Project {name: 'opencypher-tck', language: 'Gherkin'}),\n       (ada)-[:WORKS_ON {since: 2024}]->(relate),\n       (grace)-[:WORKS_ON {since: 2023}]->(relate),\n       (grace)-[:WORKS_ON {since: 2022}]->(tck),\n       (noor)-[:MAINTAINS]->(relate),\n       (ada)-[:KNOWS]->(grace)`\n\nfunc run(conn *relate.Connection, label, statement string) *relate.Result {\n\tres, err := conn.Query(statement)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tfmt.Printf(\"%s: type=%s namespace=%s bookmark=%q columns=%v\\n\", label, res.QueryType, res.Namespace, res.Bookmark, res.Columns)\n\treturn res\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\n\tcreated := run(conn, \"create\", team)\n\ts := created.Stats\n\tfmt.Println(\"  nodes\", s.NodesCreated, \"relationships\", s.RelationshipsCreated, \"properties\", s.PropertiesSet, \"labels\", s.LabelsAdded)\n\trun(conn, \"read\", \"MATCH (p:Person) RETURN p.name AS name\")\n\tupdated := run(conn, \"update\", \"MATCH (p:Person {name: 'Ada'}) SET p.role = 'lead' RETURN p.role AS role\")\n\tfmt.Println(\"  properties\", updated.Stats.PropertiesSet)\n\tindex := run(conn, \"index\", \"CREATE INDEX person_name FOR (p:Person) ON (p.name)\")\n\tfmt.Println(\"  indexes\", index.Stats.IndexesAdded)\n\trun(conn, \"routed\", \"USE system SHOW DATABASES YIELD name RETURN name\")\n\n\texplained := run(conn, \"explain\", \"EXPLAIN MATCH (a:Person), (b:Project) RETURN a.name, b.name\")\n\tfmt.Println(\"plan root:\", explained.Plan.Root.Operator)\n\tfor _, n := range explained.Notifications {\n\t\tfmt.Println(n.GQLStatus, n.Severity, n.Title)\n\t\tfmt.Println(\"remedy:\", n.Remedy)\n\t}\n}",
  "code_sha256": "9a901564564738f235df1ca4309ac8f9857ebb6309e256876a9cfc5b800bd444",
  "source_sha256": "d1a950fb03d1beb6dcb7a570da6b1b08d04b00d6a0b6915d46d10dcef0ed061f",
  "output": {
    "text": "create: type=w namespace=neo4j bookmark=\"relate:1\" columns=[]\n  nodes 5 relationships 5 properties 13 labels 5\nread: type=r namespace=neo4j bookmark=\"\" columns=[name]\nupdate: type=rw namespace=neo4j bookmark=\"relate:2\" columns=[role]\n  properties 1\nindex: type=s namespace=neo4j bookmark=\"relate:3\" columns=[]\n  indexes 1\nrouted: type=r namespace=system bookmark=\"\" columns=[name]\nexplain: type=r namespace=neo4j bookmark=\"\" columns=[]\nplan root: ProduceResults\n03N90 INFORMATION Cartesian product\nremedy: Give the patterns a join anchor: reuse a node variable across them, or add a pattern that relates their endpoints; otherwise run them as separate queries.",
    "sha256": "df96f36fda387b4c22d153edbda0bd725739cb958564b46109a0680e2b7d4530"
  },
  "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)"
    }
  }
}
