feat: Add fixed-size array support to the Go code generator#8974
feat: Add fixed-size array support to the Go code generator#8974statxc wants to merge 5 commits intogoogle:masterfrom
Conversation
|
@jtdavis777 would you review this PR |
|
this is also a language I am not familiar with, and that I think we do not have an active maintainer of. so will take me some time |
5a05954 to
b9564b4
Compare
|
@jtdavis777 could you give me any updates for me? |
|
this looks like another chunky feature that will take me a little bit to digest -- what I can say is there is a |
…o/fixed-size-array-support
Good call on
Happy to close either gap if you want full parity. |
|
thanks for the explanation -- I didn't catch in my quick scan of your PR that you had already enabled. I don't think absolute parity is necessary out of the gate as long as basic functionality is present. I will do my best to review this (with some of my free time next week most likely) but I would also love to see if I can ping someone else familiar with flatbuffers Go to chime in |
|
@mustiikhalil do you have any Go experience? :) |
|
I am pretty sure there are some example FBS files that ensure that flatc can generate code for them and at least one of them is a dedicated arrays test. can you poke around and see if we can make sure Go is one of the languages tested with that? |
|
@jtdavis777 Good catch. I looked into it and there are two things I need to hook up:
I'll get both of those wired up. |
…o/fixed-size-array-support
33c56b7 to
c05dbb2
Compare
Updated! please review again @jtdavis777 |
|
test side LGTM - would still love to find another golang person to look this over |
Summary
Add fixed-size array support to the Go code generator, resolving a long-standing gap where Go was the only major language without support for the
[type:length]struct field syntax (fixes #8417).Changes
src/idl_parser.cpp: AddIDLOptions::kGoto theSupportsAdvancedArrayFeatures()allowlist.src/idl_gen_go.cpp: Implement array-aware code generation for Go, including:[N]Type)tests/go_arrays_test_test.go: Comprehensive test covering read, mutate, object API round-trip, and standalone struct creation against thearrays_test.fbsschema.tests/GoArraysTest.sh: Test runner script following the same pattern asGoTest.sh.Design
The implementation follows the same flattening strategy used by the Java and C# generators: nested struct array fields are expanded into per-sub-field slices in the
Createfunction signature. For example,d:[NestedStruct:2]becomesd_a [][]int32, d_b []TestEnum, d_c [][]TestEnum, d_d [][]int64. Field offsets were verified against the Java reference output.Test plan
go vetclean on generated codeTestArrayStructRead,TestArrayStructMutate,TestArrayStructObjectAPI,TestNestedStructStandalone)GoTest.sh) still passflatcbuilds with no warnings