diff --git a/.golangci.yml b/.golangci.yml index 14f486085..d7a698e69 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -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. \ No newline at end of file + - errorlint + - goerr113 \ No newline at end of file diff --git a/builder_test.go b/builder_test.go index abe79bbbb..07775662e 100644 --- a/builder_test.go +++ b/builder_test.go @@ -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 @@ -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)) diff --git a/compress/snappy/xerial_test.go b/compress/snappy/xerial_test.go index fc91a42b2..72d3b5c8a 100644 --- a/compress/snappy/xerial_test.go +++ b/compress/snappy/xerial_test.go @@ -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 diff --git a/protocol.go b/protocol.go index 7c3559f72..829fabf54 100644 --- a/protocol.go +++ b/protocol.go @@ -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{