Code Generation Overview¶
traverse-gen reads an EDMX metadata document and generates a fully typed Go client, entity structs, and a query builder - eliminating hand-written boilerplate and catching type mismatches at compile time.
What gets generated¶
Given an EDMX file, traverse-gen produces:
| Output | Description |
|---|---|
| Entity structs | Go structs with correct field types and JSON tags |
| Client | Service client with one method per entity set |
| Query builders | Typed .Filter(), .Select(), .Expand() per entity |
| Enum types | Go const blocks for OData enum members |
Prerequisites¶
- Go 1.24+
- Access to the OData service metadata endpoint (
$metadata)
Quickstart¶
# Fetch metadata and generate
traverse-gen \
--metadata https://services.odata.org/V4/Northwind/Northwind.svc/$metadata \
--out gen/ \
--package northwind
This creates gen/client.go, gen/entities.go, and gen/queries.go.
Using the generated client¶
import "myapp/gen/northwind"
base, err := traverse.New(
traverse.WithBaseURL("https://services.odata.org/V4/Northwind/Northwind.svc/"),
)
if err != nil {
log.Fatal(err)
}
northwindClient := northwind.NewClient(base)
products, err := northwindClient.Products().
Filter(northwind.Product.Price.Gt(100)).
Select(northwind.Product.Name, northwind.Product.Price).
Top(10).
List(ctx)
Next steps¶
- Installation - install
traverse-gen - Usage - all CLI flags and options
- Type Mapping - how OData types map to Go
- Generated Client - working with generated code