From 0e2cc16ca1b0edf7cf3dfc76b54560cf607f3fbb Mon Sep 17 00:00:00 2001 From: web3-bot Date: Mon, 14 Aug 2023 11:06:31 +0000 Subject: [PATCH 1/2] chore: bump go.mod to Go 1.20 and run go fix --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 6d22721..0585908 100644 --- a/go.mod +++ b/go.mod @@ -18,4 +18,4 @@ require ( go.uber.org/zap v1.10.0 // indirect ) -go 1.19 +go 1.20 From a05881d01fba201ee90b961704bb4802a5cbd81a Mon Sep 17 00:00:00 2001 From: web3-bot Date: Tue, 15 Aug 2023 12:17:42 +0200 Subject: [PATCH 2/2] fix: stop using rand.Seed --- flatfs.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/flatfs.go b/flatfs.go index 2f4e400..e7ff0c7 100644 --- a/flatfs.go +++ b/flatfs.go @@ -109,8 +109,12 @@ var ( ErrInvalidKey = errors.New("key not supported by flatfs") ) +var ( + r *rand.Rand +) + func init() { - rand.Seed(time.Now().UTC().UnixNano()) + r = rand.New(rand.NewSource(time.Now().UTC().UnixNano())) } // Datastore implements the go-datastore Interface. @@ -866,7 +870,7 @@ func folderSize(path string, deadline time.Time) (int64, initAccuracy, error) { // randomize file order // https://stackoverflow.com/a/42776696 for i := len(files) - 1; i > 0; i-- { - j := rand.Intn(i + 1) + j := r.Intn(i + 1) files[i], files[j] = files[j], files[i] }