From c198b0137d8018a6514b0a4029e506c654314c3c Mon Sep 17 00:00:00 2001 From: Reinier Schoof Date: Mon, 17 Jan 2022 08:44:37 +0100 Subject: [PATCH] enabled ineffassign in golangci --- .golangci.yml | 2 +- client/resp.go | 3 +-- client/stmt.go | 2 +- mysql/mysql_test.go | 1 + mysql/rowdata.go | 2 +- replication/event.go | 4 ++-- replication/replication_test.go | 2 -- server/stmt.go | 2 +- 8 files changed, 8 insertions(+), 10 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 997630c58..94d42e4c1 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -16,9 +16,9 @@ linters: - unconvert - whitespace - govet + - ineffassign # ToDo: #- gosimple - #- ineffassign #- gocritic #- golint linters-settings: diff --git a/client/resp.go b/client/resp.go index 94524000f..1f3e81c25 100644 --- a/client/resp.go +++ b/client/resp.go @@ -53,14 +53,13 @@ func (c *Conn) handleOKPacket(data []byte) (*Result, error) { //todo:strict_mode, check warnings as error r.Warnings = binary.LittleEndian.Uint16(data[pos:]) - pos += 2 } else if c.capability&CLIENT_TRANSACTIONS > 0 { r.Status = binary.LittleEndian.Uint16(data[pos:]) c.status = r.Status - pos += 2 } //new ok package will check CLIENT_SESSION_TRACK too, but I don't support it now. + // pos += 2 //skip info return r, nil diff --git a/client/stmt.go b/client/stmt.go index c9f4a1754..761b131b6 100644 --- a/client/stmt.go +++ b/client/stmt.go @@ -214,7 +214,7 @@ func (c *Conn) Prepare(query string) (*Stmt, error) { //warnings s.warnings = int(binary.LittleEndian.Uint16(data[pos:])) - pos += 2 + // pos += 2 if s.params > 0 { if err := s.conn.readUntilEOF(); err != nil { diff --git a/mysql/mysql_test.go b/mysql/mysql_test.go index 62b24f758..c0b257942 100644 --- a/mysql/mysql_test.go +++ b/mysql/mysql_test.go @@ -40,6 +40,7 @@ func (t *mysqlTestSuite) TestMysqlGTIDInterval(c *check.C) { i, err = parseInterval("1-2") c.Assert(err, check.IsNil) + c.Assert(i, check.DeepEquals, Interval{1, 3}) } func (t *mysqlTestSuite) TestMysqlGTIDIntervalSlice(c *check.C) { diff --git a/mysql/rowdata.go b/mysql/rowdata.go index c757578d2..932a735ee 100644 --- a/mysql/rowdata.go +++ b/mysql/rowdata.go @@ -27,7 +27,7 @@ func (p RowData) ParseText(f []*Field, dst []FieldValue) ([]FieldValue, error) { var v []byte var isNull bool var pos int = 0 - var n int = 0 + var n int for i := range f { v, isNull, n, err = LengthEncodedString(p[pos:]) diff --git a/replication/event.go b/replication/event.go index 9111691d2..b0370780a 100644 --- a/replication/event.go +++ b/replication/event.go @@ -91,7 +91,7 @@ func (h *EventHeader) Decode(data []byte) error { pos += 4 h.Flags = binary.LittleEndian.Uint16(data[pos:]) - pos += 2 + // pos += 2 if h.EventSize < uint32(EventHeaderSize) { return errors.Errorf("invalid event size %d, must >= 19", h.EventSize) @@ -420,7 +420,7 @@ func (e *GTIDEvent) Decode(data []byte) error { // If the most significant bit set, another 4 byte follows representing OriginalServerVersion e.ImmediateServerVersion &= ^(uint32(1) << 31) e.OriginalServerVersion = binary.LittleEndian.Uint32(data[pos:]) - pos += 4 + // pos += 4 } else { // Otherwise OriginalServerVersion == ImmediateServerVersion e.OriginalServerVersion = e.ImmediateServerVersion diff --git a/replication/replication_test.go b/replication/replication_test.go index 57513651a..dc32773a5 100644 --- a/replication/replication_test.go +++ b/replication/replication_test.go @@ -72,14 +72,12 @@ func (t *testSyncerSuite) testSync(c *C, s *BinlogStreamer) { return } - eventCount := 0 for { ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second) e, err := s.GetEvent(ctx) cancel() if err == context.DeadlineExceeded { - eventCount += 1 return } diff --git a/server/stmt.go b/server/stmt.go index 84878ed3e..87d5e08b2 100644 --- a/server/stmt.go +++ b/server/stmt.go @@ -170,7 +170,7 @@ func (c *Conn) bindStmtArgs(s *Stmt, nullBitmap, paramTypes, paramValues []byte) pos := 0 var v []byte - var n int = 0 + var n int var isNull bool var err error