Skip to content

Commit 539f8ae

Browse files
committed
lint - fix all unconvert
(cherry picked from commit 4146fd7)
1 parent 012ec3f commit 539f8ae

File tree

12 files changed

+36
-36
lines changed

12 files changed

+36
-36
lines changed

client/auth.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func (c *Conn) readInitialHandshake() error {
4646
pos := 1 + bytes.IndexByte(data[1:], 0x00) + 1
4747

4848
// connection id length is 4
49-
c.connectionID = uint32(binary.LittleEndian.Uint32(data[pos : pos+4]))
49+
c.connectionID = binary.LittleEndian.Uint32(data[pos : pos+4])
5050
pos += 4
5151

5252
c.salt = []byte{}
@@ -199,7 +199,7 @@ func (c *Conn) writeAuthHandshake() error {
199199

200200
// Charset [1 byte]
201201
// use default collation id 33 here, is utf-8
202-
data[12] = byte(DEFAULT_COLLATION_ID)
202+
data[12] = DEFAULT_COLLATION_ID
203203

204204
// SSL Connection Request Packet
205205
// http://dev.mysql.com/doc/internals/en/connection-phase-packets.html#packet-Protocol::SSLRequest

client/stmt.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func (s *Stmt) write(args ...interface{}) error {
5454
//NULL-bitmap, length: (num-params+7)
5555
nullBitmap := make([]byte, (paramsNum+7)>>3)
5656

57-
var length int = int(1 + 4 + 1 + 4 + ((paramsNum + 7) >> 3) + 1 + (paramsNum << 1))
57+
length := 1 + 4 + 1 + 4 + ((paramsNum + 7) >> 3) + 1 + (paramsNum << 1)
5858

5959
var newParamBoundFlag byte = 0
6060

@@ -90,19 +90,19 @@ func (s *Stmt) write(args ...interface{}) error {
9090
case uint16:
9191
paramTypes[i<<1] = MYSQL_TYPE_SHORT
9292
paramTypes[(i<<1)+1] = 0x80
93-
paramValues[i] = Uint16ToBytes(uint16(v))
93+
paramValues[i] = Uint16ToBytes(v)
9494
case uint32:
9595
paramTypes[i<<1] = MYSQL_TYPE_LONG
9696
paramTypes[(i<<1)+1] = 0x80
97-
paramValues[i] = Uint32ToBytes(uint32(v))
97+
paramValues[i] = Uint32ToBytes(v)
9898
case uint:
9999
paramTypes[i<<1] = MYSQL_TYPE_LONGLONG
100100
paramTypes[(i<<1)+1] = 0x80
101101
paramValues[i] = Uint64ToBytes(uint64(v))
102102
case uint64:
103103
paramTypes[i<<1] = MYSQL_TYPE_LONGLONG
104104
paramTypes[(i<<1)+1] = 0x80
105-
paramValues[i] = Uint64ToBytes(uint64(v))
105+
paramValues[i] = Uint64ToBytes(v)
106106
case bool:
107107
paramTypes[i<<1] = MYSQL_TYPE_TINY
108108
if v {

mysql/parse_binary.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func ParseBinaryUint16(data []byte) uint16 {
2020
}
2121

2222
func ParseBinaryInt24(data []byte) int32 {
23-
u32 := uint32(ParseBinaryUint24(data))
23+
u32 := ParseBinaryUint24(data)
2424
if u32&0x00800000 != 0 {
2525
u32 |= 0xFF000000
2626
}

mysql/resultset.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ func (r *Resultset) GetUint(row, column int) (uint64, error) {
142142
case uint32:
143143
return uint64(v), nil
144144
case uint64:
145-
return uint64(v), nil
145+
return v, nil
146146
case float32:
147147
return uint64(v), nil
148148
case float64:

mysql/resultset_helper.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func formatTextValue(value interface{}) ([]byte, error) {
1717
case int32:
1818
return strconv.AppendInt(nil, int64(v), 10), nil
1919
case int64:
20-
return strconv.AppendInt(nil, int64(v), 10), nil
20+
return strconv.AppendInt(nil, v, 10), nil
2121
case int:
2222
return strconv.AppendInt(nil, int64(v), 10), nil
2323
case uint8:
@@ -27,13 +27,13 @@ func formatTextValue(value interface{}) ([]byte, error) {
2727
case uint32:
2828
return strconv.AppendUint(nil, uint64(v), 10), nil
2929
case uint64:
30-
return strconv.AppendUint(nil, uint64(v), 10), nil
30+
return strconv.AppendUint(nil, v, 10), nil
3131
case uint:
3232
return strconv.AppendUint(nil, uint64(v), 10), nil
3333
case float32:
3434
return strconv.AppendFloat(nil, float64(v), 'f', -1, 64), nil
3535
case float64:
36-
return strconv.AppendFloat(nil, float64(v), 'f', -1, 64), nil
36+
return strconv.AppendFloat(nil, v, 'f', -1, 64), nil
3737
case []byte:
3838
return v, nil
3939
case string:
@@ -64,7 +64,7 @@ func formatBinaryValue(value interface{}) ([]byte, error) {
6464
case uint32:
6565
return Uint64ToBytes(uint64(v)), nil
6666
case uint64:
67-
return Uint64ToBytes(uint64(v)), nil
67+
return Uint64ToBytes(v), nil
6868
case uint:
6969
return Uint64ToBytes(uint64(v)), nil
7070
case float32:

mysql/util.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func RandomBuf(size int) ([]byte, error) {
114114

115115
// avoid to generate '\0'
116116
for i, b := range buf {
117-
if uint8(b) == 0 {
117+
if b == 0 {
118118
buf[i] = '0'
119119
}
120120
}

packet/conn.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func (c *Conn) ReadPacketTo(w io.Writer) error {
134134
}
135135

136136
length := int(uint32(c.header[0]) | uint32(c.header[1])<<8 | uint32(c.header[2])<<16)
137-
sequence := uint8(c.header[3])
137+
sequence := c.header[3]
138138

139139
if sequence != c.Sequence {
140140
return errors.Errorf("invalid sequence %d != %d", sequence, c.Sequence)

replication/event.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func (h *EventHeader) Decode(data []byte) error {
101101
}
102102

103103
func (h *EventHeader) Dump(w io.Writer) {
104-
fmt.Fprintf(w, "=== %s ===\n", EventType(h.EventType))
104+
fmt.Fprintf(w, "=== %s ===\n", h.EventType)
105105
fmt.Fprintf(w, "Date: %s\n", time.Unix(int64(h.Timestamp), 0).Format(TimeFormat))
106106
fmt.Fprintf(w, "Log position: %d\n", h.LogPos)
107107
fmt.Fprintf(w, "Event size: %d\n", h.EventSize)
@@ -310,7 +310,7 @@ func (e *QueryEvent) Decode(data []byte) error {
310310
e.ExecutionTime = binary.LittleEndian.Uint32(data[pos:])
311311
pos += 4
312312

313-
schemaLength := uint8(data[pos])
313+
schemaLength := data[pos]
314314
pos++
315315

316316
e.ErrorCode = binary.LittleEndian.Uint16(data[pos:])
@@ -369,15 +369,15 @@ type GTIDEvent struct {
369369

370370
func (e *GTIDEvent) Decode(data []byte) error {
371371
pos := 0
372-
e.CommitFlag = uint8(data[pos])
372+
e.CommitFlag = data[pos]
373373
pos++
374374
e.SID = data[pos : pos+SidLength]
375375
pos += SidLength
376376
e.GNO = int64(binary.LittleEndian.Uint64(data[pos:]))
377377
pos += 8
378378

379379
if len(data) >= 42 {
380-
if uint8(data[pos]) == LogicalTimestampTypeCode {
380+
if data[pos] == LogicalTimestampTypeCode {
381381
pos++
382382
e.LastCommitted = int64(binary.LittleEndian.Uint64(data[pos:]))
383383
pos += PartLogicalTimestampLength
@@ -511,7 +511,7 @@ func (e *ExecuteLoadQueryEvent) Decode(data []byte) error {
511511
e.ExecutionTime = binary.LittleEndian.Uint32(data[pos:])
512512
pos += 4
513513

514-
e.SchemaLength = uint8(data[pos])
514+
e.SchemaLength = data[pos]
515515
pos++
516516

517517
e.ErrorCode = binary.LittleEndian.Uint16(data[pos:])
@@ -529,7 +529,7 @@ func (e *ExecuteLoadQueryEvent) Decode(data []byte) error {
529529
e.EndPos = binary.LittleEndian.Uint32(data[pos:])
530530
pos += 4
531531

532-
e.DupHandlingFlags = uint8(data[pos])
532+
e.DupHandlingFlags = data[pos]
533533

534534
return nil
535535
}
@@ -602,7 +602,7 @@ func (e *MariadbGTIDEvent) Decode(data []byte) error {
602602
pos += 8
603603
e.GTID.DomainID = binary.LittleEndian.Uint32(data[pos:])
604604
pos += 4
605-
e.Flags = uint8(data[pos])
605+
e.Flags = data[pos]
606606
pos += 1
607607

608608
if (e.Flags & BINLOG_MARIADB_FL_GROUP_COMMIT_ID) > 0 {

replication/json_binary.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ func (d *jsonBinaryDecoder) decodeObjectOrArray(data []byte, isSmall bool, isObj
149149
count := d.decodeCount(data, isSmall)
150150
size := d.decodeCount(data[offsetSize:], isSmall)
151151

152-
if d.isDataShort(data, int(size)) {
152+
if d.isDataShort(data, size) {
153153
// Before MySQL 5.7.22, json type generated column may have invalid value,
154154
// bug ref: https://bugs.mysql.com/bug.php?id=88791
155155
// As generated column value is not used in replication, we can just ignore

replication/row_event.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func (e *TableMapEvent) Decode(data []byte) error {
145145
}
146146

147147
func bitmapByteSize(columnCount int) int {
148-
return int(columnCount+7) / 8
148+
return (columnCount + 7) / 8
149149
}
150150

151151
// see mysql sql/log_event.h
@@ -1007,7 +1007,7 @@ func (e *RowsEvent) decodeValue(data []byte, tp byte, meta uint16) (v interface{
10071007

10081008
if b0&0x30 != 0x30 {
10091009
length = int(uint16(b1) | (uint16((b0&0x30)^0x30) << 4))
1010-
tp = byte(b0 | 0x30)
1010+
tp = b0 | 0x30
10111011
} else {
10121012
length = int(meta & 0xFF)
10131013
tp = b0
@@ -1050,7 +1050,7 @@ func (e *RowsEvent) decodeValue(data []byte, tp byte, meta uint16) (v interface{
10501050
n = int(nbits+7) / 8
10511051

10521052
//use int64 for bit
1053-
v, err = decodeBit(data, int(nbits), int(n))
1053+
v, err = decodeBit(data, int(nbits), n)
10541054
case MYSQL_TYPE_TIMESTAMP:
10551055
n = 4
10561056
t := binary.LittleEndian.Uint32(data)
@@ -1167,7 +1167,7 @@ func decodeString(data []byte, length int) (v string, n int) {
11671167
if length < 256 {
11681168
length = int(data[0])
11691169

1170-
n = int(length) + 1
1170+
n = length + 1
11711171
v = hack.String(data[1:n])
11721172
} else {
11731173
length = int(binary.LittleEndian.Uint16(data[0:]))
@@ -1194,9 +1194,9 @@ func decodeDecimalDecompressValue(compIndx int, data []byte, mask uint8) (size i
11941194

11951195
func decodeDecimal(data []byte, precision int, decimals int, useDecimal bool) (interface{}, int, error) {
11961196
//see python mysql replication and https://github.com/jeremycole/mysql_binlog
1197-
integral := (precision - decimals)
1198-
uncompIntegral := int(integral / digitsPerInteger)
1199-
uncompFractional := int(decimals / digitsPerInteger)
1197+
integral := precision - decimals
1198+
uncompIntegral := integral / digitsPerInteger
1199+
uncompFractional := decimals / digitsPerInteger
12001200
compIntegral := integral - (uncompIntegral * digitsPerInteger)
12011201
compFractional := decimals - (uncompFractional * digitsPerInteger)
12021202

schema/schema.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ func toUint64(i interface{}) uint64 {
393393
case uint32:
394394
return uint64(i)
395395
case uint64:
396-
return uint64(i)
396+
return i
397397
}
398398

399399
return 0

server/stmt.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func (c *Conn) writePrepare(s *Stmt) error {
6767
if s.Params > 0 {
6868
for i := 0; i < s.Params; i++ {
6969
data = data[0:4]
70-
data = append(data, []byte(paramFieldData)...)
70+
data = append(data, paramFieldData...)
7171

7272
if err := c.WritePacket(data); err != nil {
7373
return errors.Trace(err)
@@ -82,7 +82,7 @@ func (c *Conn) writePrepare(s *Stmt) error {
8282
if s.Columns > 0 {
8383
for i := 0; i < s.Columns; i++ {
8484
data = data[0:4]
85-
data = append(data, []byte(columnFieldData)...)
85+
data = append(data, columnFieldData...)
8686

8787
if err := c.WritePacket(data); err != nil {
8888
return errors.Trace(err)
@@ -195,7 +195,7 @@ func (c *Conn) bindStmtArgs(s *Stmt, nullBitmap, paramTypes, paramValues []byte)
195195
}
196196

197197
if isUnsigned {
198-
args[i] = uint8(paramValues[pos])
198+
args[i] = paramValues[pos]
199199
} else {
200200
args[i] = int8(paramValues[pos])
201201
}
@@ -209,7 +209,7 @@ func (c *Conn) bindStmtArgs(s *Stmt, nullBitmap, paramTypes, paramValues []byte)
209209
}
210210

211211
if isUnsigned {
212-
args[i] = uint16(binary.LittleEndian.Uint16(paramValues[pos : pos+2]))
212+
args[i] = binary.LittleEndian.Uint16(paramValues[pos : pos+2])
213213
} else {
214214
args[i] = int16(binary.LittleEndian.Uint16(paramValues[pos : pos+2]))
215215
}
@@ -222,7 +222,7 @@ func (c *Conn) bindStmtArgs(s *Stmt, nullBitmap, paramTypes, paramValues []byte)
222222
}
223223

224224
if isUnsigned {
225-
args[i] = uint32(binary.LittleEndian.Uint32(paramValues[pos : pos+4]))
225+
args[i] = binary.LittleEndian.Uint32(paramValues[pos : pos+4])
226226
} else {
227227
args[i] = int32(binary.LittleEndian.Uint32(paramValues[pos : pos+4]))
228228
}
@@ -247,7 +247,7 @@ func (c *Conn) bindStmtArgs(s *Stmt, nullBitmap, paramTypes, paramValues []byte)
247247
return ErrMalformPacket
248248
}
249249

250-
args[i] = float32(math.Float32frombits(binary.LittleEndian.Uint32(paramValues[pos : pos+4])))
250+
args[i] = math.Float32frombits(binary.LittleEndian.Uint32(paramValues[pos : pos+4]))
251251
pos += 4
252252
continue
253253

0 commit comments

Comments
 (0)