This package generates Go clients from your Codama IDLs.
pnpm install @codama/renderers-goAdd the following script to your Codama configuration file.
{
"scripts": {
"go": {
"from": "@codama/renderers-go",
"args": ["clients/go/generated"]
}
}
}Pass goModule to the render visitor to emit a go.mod next to the generated files, with the module path you provide and the Go dependency versions the generated code is built against (pinned in the renderer's goMod.njk template):
renderVisitor(path, { goModule: 'github.com/acme/my-program' });Run go mod tidy in the output folder afterwards to resolve the indirect requirements.
For every structurally distinct PDA found in the IDL (in program.pdas or inline in instruction account defaults), the renderer emits a Find<Name>PDA function in pdas.go. Constant seeds are inlined as byte literals (with a readable comment); variable seeds become typed parameters. The bump is returned alongside the address:
global, _, err := pump.FindGlobalPDA()
bondingCurve, bump, err := pump.FindBondingCurvePDA(mint)PDAs defined under another program (for example associated token accounts) derive under that program's id automatically. Each helper's doc comment lists the instructions that use the PDA.
git clone https://github.com/codama-idl/renderers-go.git
cd renderers-go
pnpm installpnpm buildRun all tests (type checks, unit tests, e2e tests, export tests):
pnpm testOr run individual test suites:
pnpm test:types # Type checking
pnpm test:unit # Unit tests
pnpm test:e2e # End-to-end tests (generates Go code and runs `go build`)The e2e tests generate Go clients from sample IDLs and verify they compile. To manually test a specific project:
pnpm build
node e2e/generate.cjs <project> # e.g. dummy, system, memo
cd e2e/<project> && go build ./...Available e2e projects: dummy, system, memo, pump-fun, jupiter.
To add an Anchor program, convert its IDL to the Codama format first:
node e2e/anchor-to-codama.cjs path/to/anchor-idl.json e2e/<project>/idl.jsonpnpm lint # Check for issues
pnpm lint:fix # Auto-fix issues