tsgen

command
v0.17.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 9, 2026 License: MIT Imports: 8 Imported by: 0

README

RPC TS Generation Example

This example shows an end-to-end pipeline for generating TypeScript RPC contracts from Go endpoint metadata.

It demonstrates endpoint-first registration with explicit typed endpoints via rpc.NewEndpoint (tasks.create, tasks.list, search.rebuild_index).

What it produces

  1. Endpoint manifest JSON at .tmp/rpc-endpoints.json
  2. TypeScript scaffold contracts at .tmp/rpc-contract.ts

Run manually

From repository root:

go run ./examples/rpc/tsgen -manifest ./examples/rpc/tsgen/.tmp/rpc-endpoints.json
go run ./cmd/rpc-tsgen \
  -manifest ./examples/rpc/tsgen/.tmp/rpc-endpoints.json \
  -out ./examples/rpc/tsgen/.tmp/rpc-contract.ts \
  -export exampleRPCMeta

Run with go generate

go generate ./examples/rpc/tsgen

This uses the //go:generate directives in main.go to run both steps.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL