fix(protogen): use strings.LastIndex to trim first field name from predefined struct name#352
Merged
fix(protogen): use strings.LastIndex to trim first field name from predefined struct name#352
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #352 +/- ##
==========================================
+ Coverage 73.86% 73.89% +0.02%
==========================================
Files 87 87
Lines 8587 8595 +8
==========================================
+ Hits 6343 6351 +8
Misses 1690 1690
Partials 554 554 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
wenchy
requested changes
Feb 5, 2026
| xerrors.KeyTrimmedNameCell, trimmedNameCell) | ||
| } | ||
| if index := strings.Index(trimmedNameCell, typeInfo.FirstFieldOptionName); index != -1 { | ||
| if index := strings.LastIndex(trimmedNameCell, typeInfo.FirstFieldOptionName); index != -1 { |
Member
There was a problem hiding this comment.
Well, if trim in reverse order, it will have a another problem if int32 (ItemID) in struct (Item) in struct (Target)
TargetItemItemID
{.Target}{.Item}int32
So the solution should be:
- If the struct's first field is not struct type, then trim in reverse order
- Otherwise, trim in forward order
Please also add test cases to cover the logic.
Collaborator
Author
There was a problem hiding this comment.
FirstFieldOptionName is parsed recursively now. New test cases added.
adb2d1f to
9411d2e
Compare
9411d2e to
0c1def5
Compare
wenchy
approved these changes
Feb 5, 2026
| xerrors.KeyTrimmedNameCell, trimmedNameCell) | ||
| } | ||
| if index := strings.Index(trimmedNameCell, typeInfo.FirstFieldOptionName); index != -1 { | ||
| if index := strings.LastIndex(trimmedNameCell, typeInfo.FirstFieldOptionName); index != -1 { |
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.
Type#314