[Go] Fix bug where bytes wasn't being imported when using --gen-onefile flag#7706
Merged
dbaileychess merged 3 commits intogoogle:masterfrom Dec 13, 2022
Merged
Conversation
enum-class
reviewed
Dec 13, 2022
enum-class
reviewed
Dec 13, 2022
enum-class
reviewed
Dec 13, 2022
dbaileychess
approved these changes
Dec 13, 2022
sunwen18
pushed a commit
to sunwen18/flatbuffers
that referenced
this pull request
Dec 25, 2022
…file flag (google#7706) * Fix bug one file import bug * Create reset import function and add braces
jochenparm
pushed a commit
to jochenparm/flatbuffers
that referenced
this pull request
Oct 29, 2024
…file flag (google#7706) * Fix bug one file import bug * Create reset import function and add braces
jochenparm
pushed a commit
to jochenparm/flatbuffers
that referenced
this pull request
Oct 29, 2024
…file flag (google#7706) * Fix bug one file import bug * Create reset import function and add braces
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.
Fix for discussion in #7460.
Currently, the go generator resets the state of needed imports each time we process an enum or struct. This works fine when we want each enum and struct to be in their own files.
However, this will lead to an error if an
fbsfile is defined like the following.When processing the
Footable theneeds_bytes_importwill be set totruebecause of the key field. Then when processing theBartable theneeds_bytes_importwill be reset tofalseresulting in the final output file to not import thebytespackage.When we want all code to be in the same file we shouldn't reset the needed imports as we iterate through the structs/enums.
Additional Changes
For the lookup function I moved the declaration of
bKeyoutside of the for loop to reduce unnecessary casting.