mirror of
https://github.com/ncruces/go-sqlite3.git
synced 2026-01-12 05:59:14 +00:00
math/rand.Read deprecated.
This commit is contained in:
4
vfs.go
4
vfs.go
@@ -2,10 +2,10 @@ package sqlite3
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"errors"
|
||||
"io"
|
||||
"io/fs"
|
||||
"math/rand"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
@@ -79,7 +79,7 @@ func vfsLocaltime(ctx context.Context, mod api.Module, t uint64, pTm uint32) uin
|
||||
|
||||
func vfsRandomness(ctx context.Context, mod api.Module, pVfs, nByte, zByte uint32) uint32 {
|
||||
mem := memory{mod}.view(zByte, nByte)
|
||||
n, _ := rand.Read(mem)
|
||||
n, _ := rand.Reader.Read(mem)
|
||||
return uint32(n)
|
||||
}
|
||||
|
||||
|
||||
11
vfs_test.go
11
vfs_test.go
@@ -5,7 +5,6 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"io/fs"
|
||||
"math/rand"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
@@ -59,18 +58,14 @@ func Test_vfsLocaltime(t *testing.T) {
|
||||
func Test_vfsRandomness(t *testing.T) {
|
||||
mem := newMemory(128)
|
||||
|
||||
rand.Seed(0)
|
||||
rc := vfsRandomness(context.TODO(), mem.mod, 0, 16, 4)
|
||||
if rc != 16 {
|
||||
t.Fatal("returned", rc)
|
||||
}
|
||||
|
||||
var want [16]byte
|
||||
rand.Seed(0)
|
||||
rand.Read(want[:])
|
||||
|
||||
if got := mem.view(4, 16); !bytes.Equal(got, want[:]) {
|
||||
t.Errorf("got %q, want %q", got, want)
|
||||
var zero [16]byte
|
||||
if got := mem.view(4, 16); bytes.Equal(got, zero[:]) {
|
||||
t.Fatal("all zero")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user