-
Type:
Task
-
Resolution: Done
-
Priority:
Unknown
-
None
-
Affects Version/s: None
-
Component/s: Evergreen
-
None
-
None
-
Go Drivers
-
None
-
None
-
None
-
None
-
None
-
None
Context
golangci-lint 2.8.0 updated prealloc https://github.com/alexkohler/prealloc/pull/56
There are now 9 instances that are flagged by golangci-lint
+ golangci-lint run --config .golangci.yml ./...
bson/benchmark_test.go:291:2: Consider preallocating cases with capacity 2 + len(destinations)*len(inputs) (prealloc)
cases := []testcase{
^
bson/value_reader_test.go:503:3: Consider preallocating doc with capacity 4 + len(codeWithScope) + 1 (prealloc)
doc := []byte{0x00, 0x00, 0x00, 0x00}
^
bson/value_reader_test.go:536:3: Consider preallocating doc with capacity 4 + len(codeWithScope) + 1 (prealloc)
doc := []byte{0x00, 0x00, 0x00, 0x00}
^
internal/integration/sessions_test.go:672:4: Consider preallocating valueArgs with capacity 1 + len(paramsValues) (prealloc)
valueArgs := []reflect.Value{reflect.ValueOf(sc)}
^
internal/integration/sessions_test.go:678:2: Consider preallocating valueArgs with capacity 1 + len(paramsValues) (prealloc)
valueArgs := []reflect.Value{reflect.ValueOf(context.Background())}
^
tag/tag.go:34:6: Consider preallocating set with capacity len(m) (prealloc)
var set Set
^
x/bsonx/bsoncore/bsoncore_test.go:875:5: Consider preallocating elems with capacity len(elem) * len(tc.elems) (prealloc)
elems := make([]byte, 0)
^
x/mongo/driver/auth/speculative_scram_test.go:246:2: Consider preallocating responses with capacity 1 + len(payloads) (prealloc)
responses := []bsoncore.Document{hello}
^
x/mongo/driver/integration/scram_test.go:151:7: Consider preallocating values with capacity len(c.mechanisms) (prealloc)
var values []bsoncore.Value
^
9 issues:
* prealloc: 9
Definition of done
Update golangci-lint to 2.8.0 in the go driver CI
Add the preallocations to clear the flagged items above.