Skip to content

Commit

Permalink
feat: add prealloc linter
Browse files Browse the repository at this point in the history
  • Loading branch information
mhmtszr committed May 31, 2024
1 parent 8e999f8 commit 4229c50
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 6 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ linters:
- unparam
- unused
- whitespace
- prealloc

service:
golangci-lint-version: 1.55.2 # use the fixed version to not introduce new linters unexpectedly
Expand Down
3 changes: 1 addition & 2 deletions connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,7 @@ func newConfig(cf any) (*config.Connector, error) {
func createKafkaClient(cc *config.Connector) (kafka.Client, error) {
kafkaClient := kafka.NewClient(cc)

var topics []string

topics := make([]string, 0, len(cc.Kafka.CollectionTopicMapping))
for _, topic := range cc.Kafka.CollectionTopicMapping {
topics = append(topics, topic)
}
Expand Down
3 changes: 1 addition & 2 deletions kafka/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ func newTLSContent(
}

func (c *client) GetEndOffsets(topic string, partitions []int) ([]kafka.PartitionOffsets, error) {
var offsetRequests []kafka.OffsetRequest

offsetRequests := make([]kafka.OffsetRequest, 0, len(partitions))
for _, partition := range partitions {
offsetRequests = append(offsetRequests, kafka.LastOffsetOf(partition))
}
Expand Down
3 changes: 1 addition & 2 deletions kafka/metadata/kafka_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ type kafkaMetadata struct {
}

func (s *kafkaMetadata) Save(state map[uint16]*models.CheckpointDocument, dirtyOffsets map[uint16]bool, _ string) error {
var messages []kafka.Message

messages := make([]kafka.Message, 0, len(state))
for vbID, document := range state {
if !dirtyOffsets[vbID] {
continue
Expand Down

0 comments on commit 4229c50

Please sign in to comment.