@@ -130,10 +130,13 @@ func AppendLengthEncodedInteger(b []byte, n uint64) []byte {
130130
131131func 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