Skip to content

Commit f66ea89

Browse files
authored
go.mod: restore Go 1.22 support (#262)
1 parent 6ad9db3 commit f66ea89

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

Diff for: filesystem/fat32/fat32_test.go

+7-14
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ package fat32_test
77

88
import (
99
"bytes"
10+
"crypto/rand"
1011
"fmt"
1112
"io"
12-
"math/rand/v2"
13+
mathrandv2 "math/rand/v2"
1314
"os"
1415
"path"
1516
"path/filepath"
@@ -249,8 +250,6 @@ func TestFat32Read(t *testing.T) {
249250
}
250251
//nolint:thelper // this is not a helper function
251252
runTest := func(t *testing.T, pre, post int64) {
252-
seed := [32]byte{}
253-
chacha := rand.NewChaCha8(seed)
254253
for _, t2 := range tests {
255254
tt := t2
256255
t.Run(fmt.Sprintf("blocksize %d filesize %d bytechange %d", tt.filesize, tt.blocksize, tt.bytechange), func(t *testing.T) {
@@ -264,7 +263,7 @@ func TestFat32Read(t *testing.T) {
264263
corrupted := ""
265264
if tt.bytechange >= 0 {
266265
b := make([]byte, 1)
267-
_, _ = chacha.Read(b)
266+
_, _ = rand.Read(b)
268267
_, _ = f.WriteAt(b, tt.bytechange+pre)
269268
corrupted = fmt.Sprintf("corrupted %d", tt.bytechange+pre)
270269
}
@@ -635,16 +634,14 @@ func TestFat32OpenFile(t *testing.T) {
635634
bWrite := make([]byte, size)
636635
header := fmt.Sprintf("OpenFile(%s, %s)", path, getOpenMode(mode))
637636
readWriter, err := fs.OpenFile(path, mode)
638-
seed := [32]byte{}
639-
chacha := rand.NewChaCha8(seed)
640637
switch {
641638
case err != nil:
642639
t.Errorf("%s: unexpected error: %v", header, err)
643640
case readWriter == nil:
644641
t.Errorf("%s: Unexpected nil output", header)
645642
default:
646643
// write and then read
647-
_, _ = chacha.Read(bWrite)
644+
_, _ = rand.Read(bWrite)
648645
written, writeErr := readWriter.Write(bWrite)
649646
_, _ = readWriter.Seek(0, 0)
650647
bRead, readErr := io.ReadAll(readWriter)
@@ -697,16 +694,14 @@ func TestFat32OpenFile(t *testing.T) {
697694
bWrite := make([]byte, size)
698695
header := fmt.Sprintf("OpenFile(%s, %s)", p, getOpenMode(mode))
699696
readWriter, err := fs.OpenFile(p, mode)
700-
seed := [32]byte{}
701-
chacha := rand.NewChaCha8(seed)
702697
switch {
703698
case err != nil:
704699
t.Fatalf("%s: unexpected error: %v", header, err)
705700
case readWriter == nil:
706701
t.Fatalf("%s: Unexpected nil output", header)
707702
default:
708703
// write and then read
709-
_, _ = chacha.Read(bWrite)
704+
_, _ = rand.Read(bWrite)
710705
written, writeErr := readWriter.Write(bWrite)
711706
_, _ = readWriter.Seek(0, 0)
712707

@@ -775,9 +770,7 @@ func TestFat32OpenFile(t *testing.T) {
775770
// success
776771
}
777772

778-
seed := [32]byte{}
779-
chacha := rand.NewChaCha8(seed)
780-
_, _ = chacha.Read(bWrite)
773+
_, _ = rand.Read(bWrite)
781774
writeSizes := []int{512, 1024, 256}
782775
low := 0
783776
for i := 0; low < len(bWrite); i++ {
@@ -1128,7 +1121,7 @@ func TestCreateFileTree(t *testing.T) {
11281121
t.Errorf("Error making microfile %s: %v", file, err)
11291122
}
11301123
file = path.Join(blobdir, "randfile")
1131-
size := rand.IntN(73) // #nosec G404
1124+
size := mathrandv2.IntN(73) // #nosec G404
11321125
if err := testMkFile(fs, file, size); err != nil {
11331126
t.Errorf("Error making random file %s: %v", file, err)
11341127
}

Diff for: go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/diskfs/go-diskfs
22

3-
go 1.23
3+
go 1.22
44

55
require (
66
github.com/djherbis/times v1.6.0

0 commit comments

Comments
 (0)