go modules (Go)

Go tooling only, with no third-party build system: a //go:generate directive beside the code that consumes the output, and a replace directive pointing the module path at the generated tree. dsdlc writes generated/go.mod, so the output is a module and needs no packaging.

Language Go
Build system go modules
Idiom A -- the generated tree is the package
Regeneration None -- regeneration is an explicit step

Notes

The require line names a version that is never fetched; replace resolves the module from disk instead, so the dependency needs no registry, vendor directory, or network.

go generate does not type-check, so the directive runs on a clean checkout where generated/ does not exist and the import cannot yet resolve.

Prerequisites

Tool Why
go runs go generate, compiles, and links

Commands

Run these from the recipe directory, with dsdl/ and src/ copied alongside it. This is the exact sequence CI runs.

# generate
go generate ./...
# build
go build -o roundtrip ./src/go
# round-trip
./roundtrip

The types this builds

The whole lanyard namespace -- twenty-four definitions, browsable from the showroom overview, where each one is paired with its wire-layout facts and a declaration excerpt in every language.

The build files

go.mod

module example.com/roundtrip

go 1.22

// Idiom A. dsdlc writes generated/go.mod declaring this module path, so it is a module in its own
// right and the only wiring needed is a replace directive pointing at where it was generated.
//
// The require line names a version that will never be fetched -- the replace takes precedence and
// resolves the module from disk. That is the standard way to depend on a module that is not
// published, and it is what makes the generated tree consumable without a registry, a vendor
// directory, or a network.
require example.com/lanyard v0.0.0

replace example.com/lanyard => ./generated