Skip to content

Commit 39e2e96

Browse files
authored
fixing [email protected] errors of current build (#912)
* fixing [email protected] errors of currenet build * more linting fixes for golangci-ling 1.60.3
1 parent ccf204b commit 39e2e96

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

driver/driver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ func (c *conn) CheckNamedValue(nv *sqldriver.NamedValue) error {
203203
} else {
204204
// we've found an error, if the error is driver.ErrSkip then
205205
// keep looking otherwise return the unknown error
206-
if !goErrors.Is(sqldriver.ErrSkip, err) {
206+
if !goErrors.Is(err, sqldriver.ErrSkip) {
207207
return err
208208
}
209209
}

mysql/util.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,13 @@ func AppendLengthEncodedInteger(b []byte, n uint64) []byte {
130130

131131
func RandomBuf(size int) []byte {
132132
buf := make([]byte, size)
133-
mrand.Seed(time.Now().UTC().UnixNano())
133+
// When this project supports golang 1.20 as a minimum, then this mrand.New(...)
134+
// line can be eliminated and the random number can be generated by simply
135+
// calling mrand.Intn()
136+
random := mrand.New(mrand.NewSource(time.Now().UTC().UnixNano()))
134137
min, max := 30, 127
135138
for i := 0; i < size; i++ {
136-
buf[i] = byte(min + mrand.Intn(max-min))
139+
buf[i] = byte(min + random.Intn(max-min))
137140
}
138141
return buf
139142
}
@@ -197,11 +200,13 @@ func PutLengthEncodedInt(n uint64) []byte {
197200
case n <= 0xffffff:
198201
return []byte{0xfd, byte(n), byte(n >> 8), byte(n >> 16)}
199202

200-
case n <= 0xffffffffffffffff:
203+
default:
204+
// handles case n <= 0xffffffffffffffff
205+
// using 'default' instead of 'case' to avoid static analysis error
206+
// SA4003: every value of type uint64 is <= math.MaxUint64
201207
return []byte{0xfe, byte(n), byte(n >> 8), byte(n >> 16), byte(n >> 24),
202208
byte(n >> 32), byte(n >> 40), byte(n >> 48), byte(n >> 56)}
203209
}
204-
return nil
205210
}
206211

207212
// LengthEncodedString returns the string read as a bytes slice, whether the value is NULL,

0 commit comments

Comments
 (0)