Commit 9ef0dac
authored
Go codegen: per-event-type data structs (#1037)
* Go codegen: per-event-type data structs (fixes #1031)
Replace the flat quicktype-generated Data union struct with per-event-type
data structs, matching the C# codegen approach. Adding a new session event
type can no longer change the struct shape of existing event types.
- Replace generateSessionEvents() in scripts/codegen/go.ts with custom
codegen that produces 74 per-event data structs, a SessionEventData
interface, and custom UnmarshalJSON/MarshalJSON on SessionEvent
- Update go/session.go to use idiomatic Go type switches for event dispatch
- Update samples, tests, and doc examples for the new API
- Add type/const aliases for PermissionRequest, Attachment, and related
types to ease migration
- Add .gitattributes eol=lf for generated files to prevent cross-platform
line ending diffs
- Re-enable the codegen-check CI workflow (remove go/generated_session_events.go
revert workaround)
- Add ui, uri, mime to Go initialisms for correct field naming
* Go codegen: use idiomatic Go doc comments on generated types
Prefix all generated type comments with the type name per Go convention
(e.g., '// SessionStartData session initialization metadata.').
* Revert "Go codegen: use idiomatic Go doc comments on generated types"
This reverts commit 8e5423b.
* Fix Go code examples in docs, scenarios, and lint warning
Update all Go code examples in docs/, test/scenarios/, and one E2E
test to use per-event type assertions instead of the old flat
event.Data.FieldName pattern.
Fix staticcheck SA5011 lint warning in tools_test.go (nil check
must precede type assertion).1 parent 8569d92 commit 9ef0dac
File tree
59 files changed
+3158
-2008
lines changed- .github/workflows
- docs
- auth
- features
- setup
- go
- internal/e2e
- testharness
- rpc
- samples
- scripts/codegen
- test/scenarios
- auth
- byok-anthropic/go
- byok-azure/go
- byok-ollama/go
- byok-openai/go
- gh-app/go
- bundling
- app-backend-to-server/go
- app-direct-server/go
- container-proxy/go
- fully-bundled/go
- callbacks
- hooks/go
- permissions/go
- user-input/go
- modes
- default/go
- minimal/go
- prompts
- attachments/go
- reasoning-effort/go
- system-message/go
- sessions
- concurrent-sessions/go
- infinite-sessions/go
- session-resume/go
- streaming/go
- tools
- custom-agents/go
- mcp-servers/go
- no-tools/go
- skills/go
- tool-filtering/go
- tool-overrides/go
- virtual-filesystem/go
- transport
- reconnect/go
- stdio/go
- tcp/go
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
59 files changed
+3158
-2008
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | 50 | | |
56 | 51 | | |
57 | 52 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
133 | | - | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
134 | 136 | | |
135 | 137 | | |
136 | 138 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
506 | 506 | | |
507 | 507 | | |
508 | 508 | | |
509 | | - | |
510 | | - | |
511 | | - | |
512 | | - | |
513 | | - | |
514 | | - | |
515 | | - | |
516 | | - | |
517 | | - | |
518 | | - | |
519 | | - | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
520 | 520 | | |
521 | 521 | | |
522 | 522 | | |
| |||
530 | 530 | | |
531 | 531 | | |
532 | 532 | | |
533 | | - | |
534 | | - | |
535 | | - | |
536 | | - | |
537 | | - | |
538 | | - | |
539 | | - | |
540 | | - | |
541 | | - | |
542 | | - | |
543 | | - | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
544 | 544 | | |
545 | 545 | | |
546 | 546 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
140 | | - | |
141 | | - | |
| 140 | + | |
| 141 | + | |
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
151 | | - | |
152 | | - | |
| 151 | + | |
| 152 | + | |
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
211 | 211 | | |
212 | 212 | | |
213 | 213 | | |
214 | | - | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
215 | 217 | | |
216 | 218 | | |
217 | 219 | | |
| |||
406 | 408 | | |
407 | 409 | | |
408 | 410 | | |
409 | | - | |
410 | | - | |
411 | | - | |
412 | | - | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
413 | 416 | | |
414 | 417 | | |
415 | 418 | | |
| |||
604 | 607 | | |
605 | 608 | | |
606 | 609 | | |
607 | | - | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
608 | 613 | | |
609 | | - | |
610 | | - | |
| 614 | + | |
| 615 | + | |
611 | 616 | | |
612 | 617 | | |
613 | 618 | | |
| |||
625 | 630 | | |
626 | 631 | | |
627 | 632 | | |
628 | | - | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
629 | 636 | | |
630 | | - | |
631 | | - | |
| 637 | + | |
| 638 | + | |
632 | 639 | | |
633 | 640 | | |
634 | 641 | | |
| |||
897 | 904 | | |
898 | 905 | | |
899 | 906 | | |
900 | | - | |
901 | | - | |
902 | | - | |
903 | | - | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
904 | 912 | | |
905 | 913 | | |
906 | 914 | | |
| |||
1251 | 1259 | | |
1252 | 1260 | | |
1253 | 1261 | | |
1254 | | - | |
1255 | | - | |
1256 | | - | |
1257 | | - | |
1258 | | - | |
1259 | | - | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
1260 | 1267 | | |
1261 | 1268 | | |
1262 | 1269 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
133 | | - | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
134 | 136 | | |
135 | 137 | | |
136 | 138 | | |
| |||
146 | 148 | | |
147 | 149 | | |
148 | 150 | | |
149 | | - | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
150 | 154 | | |
151 | 155 | | |
152 | 156 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
95 | 97 | | |
96 | 98 | | |
97 | 99 | | |
| |||
105 | 107 | | |
106 | 108 | | |
107 | 109 | | |
108 | | - | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
109 | 113 | | |
110 | 114 | | |
111 | 115 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
66 | 64 | | |
67 | 65 | | |
68 | 66 | | |
| |||
404 | 402 | | |
405 | 403 | | |
406 | 404 | | |
407 | | - | |
| 405 | + | |
| 406 | + | |
408 | 407 | | |
409 | | - | |
410 | | - | |
411 | | - | |
412 | | - | |
| 408 | + | |
| 409 | + | |
413 | 410 | | |
414 | | - | |
415 | | - | |
416 | | - | |
417 | | - | |
| 411 | + | |
| 412 | + | |
418 | 413 | | |
419 | 414 | | |
420 | | - | |
421 | | - | |
422 | | - | |
423 | | - | |
| 415 | + | |
| 416 | + | |
424 | 417 | | |
425 | 418 | | |
426 | | - | |
427 | | - | |
428 | | - | |
429 | | - | |
430 | | - | |
| 419 | + | |
| 420 | + | |
431 | 421 | | |
432 | 422 | | |
433 | 423 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
| 23 | + | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
0 commit comments