feat: Add fixed-size array support to the Go code generator#8974
Open
statxc wants to merge 3 commits intogoogle:masterfrom
Open
feat: Add fixed-size array support to the Go code generator#8974statxc wants to merge 3 commits intogoogle:masterfrom
statxc wants to merge 3 commits intogoogle:masterfrom
Conversation
Contributor
Author
|
@jtdavis777 would you review this PR |
Collaborator
|
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
Contributor
Author
|
Please any updates for me 🙏 |
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
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