From df7b65833a0f08932b678a8866c0f69f4e14cae5 Mon Sep 17 00:00:00 2001 From: ionutboangiu Date: Thu, 5 Sep 2024 18:27:25 +0300 Subject: [PATCH] remove deprecated math/rand.Seed calls see https://pkg.go.dev/math/rand#Seed --- apier/v1/stats_it_test.go | 4 ---- engine/resources.go | 4 ---- engine/sharedgroup.go | 1 - sessions/libsessions.go | 1 - sessions/sessions.go | 1 - utils/coreutils.go | 1 - 6 files changed, 12 deletions(-) diff --git a/apier/v1/stats_it_test.go b/apier/v1/stats_it_test.go index 6d395c106..3a59be703 100644 --- a/apier/v1/stats_it_test.go +++ b/apier/v1/stats_it_test.go @@ -86,10 +86,6 @@ var ( } ) -func init() { - rand.Seed(time.Now().UnixNano()) // used in benchmarks -} - // Test start here func TestSTSV1IT(t *testing.T) { switch *utils.DBType { diff --git a/engine/resources.go b/engine/resources.go index 494c8a357..e315dcbad 100644 --- a/engine/resources.go +++ b/engine/resources.go @@ -30,10 +30,6 @@ import ( "github.com/cgrates/cgrates/utils" ) -func init() { - rand.Seed(time.Now().UnixNano()) -} - // ResourceProfile represents the user configuration for the resource type ResourceProfile struct { Tenant string diff --git a/engine/sharedgroup.go b/engine/sharedgroup.go index 9039c8bca..d029b3831 100644 --- a/engine/sharedgroup.go +++ b/engine/sharedgroup.go @@ -180,7 +180,6 @@ func (rbcs *RandomBalancesSorter) Sort() { src := *rbcs // randomize balance chain dest := make([]*Balance, len(src)) - rand.Seed(time.Now().UnixNano()) perm := rand.Perm(len(src)) for i, v := range perm { dest[v] = src[i] diff --git a/sessions/libsessions.go b/sessions/libsessions.go index d4ee15290..97406a186 100644 --- a/sessions/libsessions.go +++ b/sessions/libsessions.go @@ -76,7 +76,6 @@ func getSessionTTL(ev *engine.MapEvent, cfgSessionTTL time.Duration, } sessionTTLMaxDelay = maxDelay.Nanoseconds() / 1000000 // Milliseconds precision for randomness if sessionTTLMaxDelay != 0 { - rand.Seed(time.Now().Unix()) ttl += time.Duration(rand.Int63n(sessionTTLMaxDelay) * 1000000) } return diff --git a/sessions/sessions.go b/sessions/sessions.go index c7ed94eac..3634d0959 100644 --- a/sessions/sessions.go +++ b/sessions/sessions.go @@ -247,7 +247,6 @@ func (sS *SessionS) setSTerminator(s *Session) { } } if maxDelay != 0 { - rand.Seed(time.Now().Unix()) ttl += time.Duration( rand.Int63n(maxDelay.Nanoseconds()/time.Millisecond.Nanoseconds()) * time.Millisecond.Nanoseconds()) } diff --git a/utils/coreutils.go b/utils/coreutils.go index 6c7d38403..4d8dfa008 100644 --- a/utils/coreutils.go +++ b/utils/coreutils.go @@ -64,7 +64,6 @@ var ( func init() { startCGRateSTime = time.Now() - math_rand.Seed(startCGRateSTime.UnixNano()) } // GetStartTime return the Start time of engine (in UNIX format)