Go
Requires:
-
Go 1.25.6 or later
-
linux/amd64,linux/arm64ordarwin/arm64 -
glibcandlibstdc++at runtime, so notmusl-based distributions such as Alpine
Install
go get github.com/neo4j/ontology-graph-spec/[email protected]
Read and write models
Models are Go structs with JSON tags, so read and write them with encoding/json.
import "github.com/neo4j/ontology-graph-spec/go/model"
var graph model.GraphModel
err := json.Unmarshal(content, &graph)
| The Go library currently only supports JSON. |
Validate models
import "github.com/neo4j/ontology-graph-spec/go/validation"
issues, err := validation.Validate(graph, validation.SetCore)
Pass more than one set to check against all of them, such as validation.Validate(graph, validation.SetCore,
validation.SetLabelled).
See Validation for the validator sets and issues.
Native library
Validation runs in a native library embedded in the module and loaded on first use.
If you want to load the library from a custom location, set GRAPHDATAMODEL_LIB_PATH to the path of the library for
your platform, copied from go/internal/bridge/lib/ in the repository.
The native library has its own heap, which counts towards the process’s memory but isn’t bounded by GOMEMLIMIT. To cap
the heap, for example to avoid issues relating to extremely large documents or many concurrent calls, set
GRAPHSPEC_MAX_HEAP_BYTES.
| See the Go README in the repository for more information on native library loading and building the Go library. |