Protobuf Go/TS Schema Exchange
Quick start
- •Define a protobuf schema with a
schema_versionfield and stable package name. - •Configure Buf v2 with
remote:plugins and generate Go + TS outputs. - •Emit JSON in Go using
protojson(camelCase field names). - •Decode JSON in TS using
fromJsonand validateint64and Struct behaviors.
Workflow
- •Author the protobuf schema (see
references/templates.md). - •Configure Buf v2 generation for Go + TS (see
references/templates.md). - •Generate outputs with
buf generate. - •Emit JSON in Go with
protojsonand a SEM-style envelope. - •Decode in TS with
fromJsonand validate BigInt/Struct handling. - •Run the validation checklist (see
references/validation.md).
Pitfalls to avoid
- •Use Buf v2
remote:plugin syntax inbuf.gen.yaml. - •Match protoc-gen-es v2 with
@bufbuild/protobufv2. - •Expect
int64in JSON to be strings;fromJsonyieldsbigint. - •
google.protobuf.Structbecomes a JsonObject in TS, not a Struct message. - •With
paths=source_relative, generated outputs keep theproto/prefix; aligngo_packageaccordingly.
References
- •
references/templates.md - •
references/validation.md