Skip to content

Commit

Permalink
go.mod: restore Go 1.22 support (#262)
Browse files Browse the repository at this point in the history
  • Loading branch information
AkihiroSuda authored Oct 7, 2024
1 parent 6ad9db3 commit f66ea89
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
21 changes: 7 additions & 14 deletions filesystem/fat32/fat32_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ package fat32_test

import (
"bytes"
"crypto/rand"
"fmt"
"io"
"math/rand/v2"
mathrandv2 "math/rand/v2"
"os"
"path"
"path/filepath"
Expand Down Expand Up @@ -249,8 +250,6 @@ func TestFat32Read(t *testing.T) {
}
//nolint:thelper // this is not a helper function
runTest := func(t *testing.T, pre, post int64) {
seed := [32]byte{}
chacha := rand.NewChaCha8(seed)
for _, t2 := range tests {
tt := t2
t.Run(fmt.Sprintf("blocksize %d filesize %d bytechange %d", tt.filesize, tt.blocksize, tt.bytechange), func(t *testing.T) {
Expand All @@ -264,7 +263,7 @@ func TestFat32Read(t *testing.T) {
corrupted := ""
if tt.bytechange >= 0 {
b := make([]byte, 1)
_, _ = chacha.Read(b)
_, _ = rand.Read(b)
_, _ = f.WriteAt(b, tt.bytechange+pre)
corrupted = fmt.Sprintf("corrupted %d", tt.bytechange+pre)
}
Expand Down Expand Up @@ -635,16 +634,14 @@ func TestFat32OpenFile(t *testing.T) {
bWrite := make([]byte, size)
header := fmt.Sprintf("OpenFile(%s, %s)", path, getOpenMode(mode))
readWriter, err := fs.OpenFile(path, mode)
seed := [32]byte{}
chacha := rand.NewChaCha8(seed)
switch {
case err != nil:
t.Errorf("%s: unexpected error: %v", header, err)
case readWriter == nil:
t.Errorf("%s: Unexpected nil output", header)
default:
// write and then read
_, _ = chacha.Read(bWrite)
_, _ = rand.Read(bWrite)
written, writeErr := readWriter.Write(bWrite)
_, _ = readWriter.Seek(0, 0)
bRead, readErr := io.ReadAll(readWriter)
Expand Down Expand Up @@ -697,16 +694,14 @@ func TestFat32OpenFile(t *testing.T) {
bWrite := make([]byte, size)
header := fmt.Sprintf("OpenFile(%s, %s)", p, getOpenMode(mode))
readWriter, err := fs.OpenFile(p, mode)
seed := [32]byte{}
chacha := rand.NewChaCha8(seed)
switch {
case err != nil:
t.Fatalf("%s: unexpected error: %v", header, err)
case readWriter == nil:
t.Fatalf("%s: Unexpected nil output", header)
default:
// write and then read
_, _ = chacha.Read(bWrite)
_, _ = rand.Read(bWrite)
written, writeErr := readWriter.Write(bWrite)
_, _ = readWriter.Seek(0, 0)

Expand Down Expand Up @@ -775,9 +770,7 @@ func TestFat32OpenFile(t *testing.T) {
// success
}

seed := [32]byte{}
chacha := rand.NewChaCha8(seed)
_, _ = chacha.Read(bWrite)
_, _ = rand.Read(bWrite)
writeSizes := []int{512, 1024, 256}
low := 0
for i := 0; low < len(bWrite); i++ {
Expand Down Expand Up @@ -1128,7 +1121,7 @@ func TestCreateFileTree(t *testing.T) {
t.Errorf("Error making microfile %s: %v", file, err)
}
file = path.Join(blobdir, "randfile")
size := rand.IntN(73) // #nosec G404
size := mathrandv2.IntN(73) // #nosec G404
if err := testMkFile(fs, file, size); err != nil {
t.Errorf("Error making random file %s: %v", file, err)
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/diskfs/go-diskfs

go 1.23
go 1.22

require (
github.com/djherbis/times v1.6.0
Expand Down

0 comments on commit f66ea89

Please sign in to comment.