Generate Go bool discriminated unions#1284
Merged
stephentoub merged 1 commit intoMay 14, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Go code generator to support boolean-valued discriminators in JSON-schema anyOf discriminated unions, and regenerates Go RPC types/encoding so QueuedCommandResult is modeled as a boolean-discriminated interface (preserving the handled discriminator across marshal/unmarshal).
Changes:
- Extend Go codegen discriminator detection to accept
const/enumbooleans (in addition to strings), including correct variant naming and switch emission. - Regenerate Go RPC types so
QueuedCommandResultbecomes an interface withHandled() bool, with concrete handled/not-handled variants plus a raw fallback. - Regenerate Go RPC JSON encoding to unmarshal/marshal
QueuedCommandResultwhile preserving the discriminator (handled) correctly.
Show a summary per file
| File | Description |
|---|---|
| scripts/codegen/go.ts | Adds boolean discriminator support for discriminated unions and improves boolean schema merging for flattened object unions. |
| go/rpc/zrpc.go | Regenerates QueuedCommandResult as a boolean-discriminated interface with handled/not-handled variants. |
| go/rpc/zrpc_encoding.go | Adds generated marshal/unmarshal support for the new QueuedCommandResult union and updates request decoding accordingly. |
Copilot's findings
Files not reviewed (2)
- go/rpc/zrpc.go: Language not supported
- go/rpc/zrpc_encoding.go: Language not supported
- Files reviewed: 1/3 changed files
- Comments generated: 0
8e2bcb2 to
9889a0d
Compare
9889a0d to
cb0db3a
Compare
cb0db3a to
e125082
Compare
stephentoub
approved these changes
May 14, 2026
Collaborator
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
QueuedCommandResultas a boolean-discriminated interface instead of a flattened structhandledis preserved when marshaling and unmarshaling queued command resultsFixes #1264
Testing
npm run generate:gogo test ./rpcgo test .