Skip to content

Commit

Permalink
simplify golangci-lint config, autofix
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicbarnes committed May 16, 2022
1 parent f617121 commit e02eb7b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 35 deletions.
35 changes: 11 additions & 24 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,14 @@
linters:
enable-all: true
enable:
- bodyclose
- goconst
- godot
- gofmt
- goimports
- prealloc

disable:
# errcheck flags a lot of issues that we don't find valid, especially as
# fixing them has the potential to change behavior.
# Temporarily disabling so it can be addressed in a dedicated PR.
- errcheck

# these linters are either deprecated or unhelpful, so likely they will not
# be used in the future
- exhaustivestruct
- golint
- interfacer
- maligned
- scopelint
- testpackage

linters-settings:
# While not enabled atm, errcheck could be enabled in the future, so leaving
# behind the config here for now.
errcheck:
check-type-assertions: true
check-blank: true

# One notable gap in the configuration here is the ability to exclude test
# files, which appears to be supported by the errcheck linter itself, but is
# not part of the config struct contained in golangci-lint. This seems like
# a good candidate for a first-time contribution to golangci-lint.
- errorlint
- goerr113
18 changes: 9 additions & 9 deletions builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func (f v1MessageSetBuilder) bytes() []byte {
})
if f.codec != nil {
bs = newWB().call(func(wb *kafkaWriteBuffer) {
wb.writeInt64(f.msgs[len(f.msgs)-1].Offset) // offset of the wrapper message is the last offset of the inner messages
wb.writeInt64(f.msgs[len(f.msgs)-1].Offset) // offset of the wrapper message is the last offset of the inner messages
wb.writeBytes(newWB().call(func(wb *kafkaWriteBuffer) {
bs := mustCompress(bs, f.codec)
wb.writeInt32(-1) // crc, unused
Expand Down Expand Up @@ -194,14 +194,14 @@ func (f v2MessageSetBuilder) bytes() []byte {
for i, msg := range f.msgs {
wb.Write(newWB().call(func(wb *kafkaWriteBuffer) {
bs := newWB().call(func(wb *kafkaWriteBuffer) {
wb.writeInt8(0) // record attributes, not used here
wb.writeVarInt(1000 * (time.Now().Unix() - msg.Time.Unix())) // timestamp
wb.writeVarInt(int64(i)) // offset delta
wb.writeVarInt(int64(len(msg.Key))) // key len
wb.Write(msg.Key) // key bytes
wb.writeVarInt(int64(len(msg.Value))) // value len
wb.Write(msg.Value) // value bytes
wb.writeVarInt(int64(len(msg.Headers))) // number of headers
wb.writeInt8(0) // record attributes, not used here
wb.writeVarInt(1000 * (time.Now().Unix() - msg.Time.Unix())) // timestamp
wb.writeVarInt(int64(i)) // offset delta
wb.writeVarInt(int64(len(msg.Key))) // key len
wb.Write(msg.Key) // key bytes
wb.writeVarInt(int64(len(msg.Value))) // value len
wb.Write(msg.Value) // value bytes
wb.writeVarInt(int64(len(msg.Headers))) // number of headers
for _, header := range msg.Headers {
wb.writeVarInt(int64(len(header.Key)))
wb.Write([]byte(header.Key))
Expand Down
2 changes: 1 addition & 1 deletion compress/snappy/xerial_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"io"
"testing"

goxerialsnappy "github.com/segmentio/kafka-go/compress/snappy/go-xerial-snappy"
"github.com/klauspost/compress/snappy"
goxerialsnappy "github.com/segmentio/kafka-go/compress/snappy/go-xerial-snappy"
)

// Wrap an io.Reader or io.Writer to disable all copy optimizations like
Expand Down
2 changes: 1 addition & 1 deletion protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ const (
v7 = 7
v10 = 10

// Unused protocol versions: v4, v6, v8, v9
// Unused protocol versions: v4, v6, v8, v9.
)

var apiKeyStrings = [...]string{
Expand Down

0 comments on commit e02eb7b

Please sign in to comment.