From e3ecd8fef07ab3d5ccc00eebf53b05e332135033 Mon Sep 17 00:00:00 2001 From: Sergey Stepanov Date: Thu, 6 Apr 2023 20:39:41 +0300 Subject: [PATCH] Remove not needed rand seeding --- cmd/coordinator/main.go | 4 ---- cmd/worker/main.go | 2 -- pkg/worker/compression/zip/compression_test.go | 3 --- pkg/worker/emulator/libretro/frontend_test.go | 1 - pkg/worker/media_test.go | 3 --- pkg/worker/recorder/recorder.go | 4 ---- 6 files changed, 17 deletions(-) diff --git a/cmd/coordinator/main.go b/cmd/coordinator/main.go index 1e98632b..bc1a99be 100644 --- a/cmd/coordinator/main.go +++ b/cmd/coordinator/main.go @@ -1,9 +1,6 @@ package main import ( - "math/rand" - "time" - config "github.com/giongto35/cloud-game/v3/pkg/config/coordinator" "github.com/giongto35/cloud-game/v3/pkg/coordinator" "github.com/giongto35/cloud-game/v3/pkg/logger" @@ -13,7 +10,6 @@ import ( var Version = "?" func main() { - rand.New(rand.NewSource(time.Now().UnixNano())) // !to remove when bumped to 1.20 conf := config.NewConfig() conf.ParseFlags() diff --git a/cmd/worker/main.go b/cmd/worker/main.go index e19d6839..9c4af846 100644 --- a/cmd/worker/main.go +++ b/cmd/worker/main.go @@ -1,7 +1,6 @@ package main import ( - "math/rand" "time" config "github.com/giongto35/cloud-game/v3/pkg/config/worker" @@ -14,7 +13,6 @@ import ( var Version = "?" func run() { - rand.New(rand.NewSource(time.Now().UnixNano())) // !to remove when bumped to 1.20 conf := config.NewConfig() conf.ParseFlags() diff --git a/pkg/worker/compression/zip/compression_test.go b/pkg/worker/compression/zip/compression_test.go index 0092a267..f193ca15 100644 --- a/pkg/worker/compression/zip/compression_test.go +++ b/pkg/worker/compression/zip/compression_test.go @@ -3,10 +3,8 @@ package zip import ( cr "crypto/rand" "fmt" - "math/rand" "reflect" "testing" - "time" ) func TestCompression(t *testing.T) { @@ -63,7 +61,6 @@ func BenchmarkCompressions(b *testing.B) { {name: "compress", size: 1024 * 1024 * 2}, } for _, bm := range benchmarks { - rand.New(rand.NewSource(time.Now().UnixNano())) // !to remove when bumped to 1.20 b.Run(fmt.Sprintf("%v %v", bm.name, bm.size), func(b *testing.B) { b.StopTimer() dat := make([]byte, bm.size) diff --git a/pkg/worker/emulator/libretro/frontend_test.go b/pkg/worker/emulator/libretro/frontend_test.go index 6a2e0ad1..b9225a80 100644 --- a/pkg/worker/emulator/libretro/frontend_test.go +++ b/pkg/worker/emulator/libretro/frontend_test.go @@ -167,7 +167,6 @@ func TestStateConcurrency(t *testing.T) { }) mock.handleAudio(func(_ *emulator.GameAudio) {}) - rand.New(rand.NewSource(int64(test.seed))) // !to remove when bumped to 1.20 t.Logf("Random seed is [%v]\n", test.seed) t.Logf("Save path is [%v]\n", mock.paths.save) diff --git a/pkg/worker/media_test.go b/pkg/worker/media_test.go index 96eb4ee5..7086a51f 100644 --- a/pkg/worker/media_test.go +++ b/pkg/worker/media_test.go @@ -6,7 +6,6 @@ import ( "math/rand" "reflect" "testing" - "time" "github.com/giongto35/cloud-game/v3/pkg/logger" "github.com/giongto35/cloud-game/v3/pkg/worker/encoder" @@ -138,8 +137,6 @@ func BenchmarkResampler(b *testing.B) { } func gen(l int) []int16 { - rand.New(rand.NewSource(time.Now().UnixNano())) // !to remove when bumped to 1.20 - nums := make([]int16, l) for i := range nums { nums[i] = int16(rand.Intn(10)) diff --git a/pkg/worker/recorder/recorder.go b/pkg/worker/recorder/recorder.go index c7ba8c33..961e9191 100644 --- a/pkg/worker/recorder/recorder.go +++ b/pkg/worker/recorder/recorder.go @@ -65,10 +65,6 @@ type ( } ) -func init() { - rand.New(rand.NewSource(time.Now().UnixNano())) // !to remove when bumped to 1.20 -} - // NewRecording creates new media recorder for the emulator. func NewRecording(meta Meta, log *logger.Logger, opts Options) *Recording { savePath, err := filepath.Abs(opts.Dir)