-
Notifications
You must be signed in to change notification settings - Fork 2.3k
golangci-lint: add prealloc linter + manually fix problems
#18901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 7 commits
79c65a1
a485e26
5418646
93d7588
2712f65
6deb8d9
bdd3128
9e5aeb6
2c5f610
46a5677
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -99,14 +99,14 @@ func ReplaceFields(result *Result, remap map[string]string) *Result { | |
| } | ||
| } | ||
|
|
||
| var fields []*querypb.Field | ||
| fields := make([]*querypb.Field, 0, len(fieldIdx)) | ||
| for _, name := range fieldIdx { | ||
| fields = append(fields, result.Fields[orig[name]]) | ||
| } | ||
|
|
||
| fields = fields[:len(result.Fields)-len(remap)] | ||
|
|
||
| var rows []Row | ||
| rows := make([]Row, 0, len(result.Rows)) | ||
| for _, origRow := range result.Rows { | ||
| var row []Value | ||
| for _, name := range rowIdx { | ||
|
|
@@ -142,13 +142,15 @@ func MarshalResult(v any) (*Result, error) { | |
| elem := val.Type().Elem() | ||
| elemType := elem.Elem() | ||
|
|
||
| visibleFields := reflect.VisibleFields(elemType) | ||
|
|
||
| var ( | ||
| exportedStructFields []reflect.StructField | ||
| fields []*querypb.Field | ||
| rows []Row | ||
| exportedStructFields = make([]reflect.StructField, 0, len(visibleFields)) | ||
| fields = make([]*querypb.Field, 0, len(visibleFields)) | ||
| rows = make([]Row, 0, val.Len()) | ||
|
Comment on lines
+148
to
+150
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Claude pointed out here that the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this is expected because we sometimes |
||
| ) | ||
|
|
||
| for _, field := range reflect.VisibleFields(elemType) { | ||
| for _, field := range visibleFields { | ||
| if !field.IsExported() { | ||
| continue | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.