mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
lint: Fix SA1019
Using a deprecated function
`rand.Read` has been deprecated since Go 1.20 `crypto/rand.Read` is more appropriate Ref: https://tip.golang.org/doc/go1.20 Signed-off-by: Michal Biesek <michalbiesek@gmail.com>
This commit is contained in:
parent
7d1110a679
commit
04d7b4dbee
|
@ -16,11 +16,12 @@ package wlog
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"crypto/rand"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"fmt"
|
"fmt"
|
||||||
"hash/crc32"
|
"hash/crc32"
|
||||||
"io"
|
"io"
|
||||||
"math/rand"
|
"math/big"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
@ -252,8 +253,11 @@ func generateRandomEntries(w *WL, records chan []byte) error {
|
||||||
default:
|
default:
|
||||||
sz = pageSize * 8
|
sz = pageSize * 8
|
||||||
}
|
}
|
||||||
|
n, err := rand.Int(rand.Reader, big.NewInt(sz))
|
||||||
rec := make([]byte, rand.Int63n(sz))
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
rec := make([]byte, n.Int64())
|
||||||
if _, err := rand.Read(rec); err != nil {
|
if _, err := rand.Read(rec); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -262,7 +266,11 @@ func generateRandomEntries(w *WL, records chan []byte) error {
|
||||||
|
|
||||||
// Randomly batch up records.
|
// Randomly batch up records.
|
||||||
recs = append(recs, rec)
|
recs = append(recs, rec)
|
||||||
if rand.Intn(4) < 3 {
|
n, err = rand.Int(rand.Reader, big.NewInt(int64(4)))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if int(n.Int64()) < 3 {
|
||||||
if err := w.Log(recs...); err != nil {
|
if err := w.Log(recs...); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,9 +16,9 @@ package wlog
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"crypto/rand"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"math/rand"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
Loading…
Reference in a new issue