diff options
| author | 1911860538 <alxps1911@gmail.com> | 2025-11-24 12:17:25 +0000 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2026-01-22 07:35:48 -0800 |
| commit | 0f9cdc2fbc8de4ffed049284b1b42c0496d9e05d (patch) | |
| tree | be34814b17063e0a7baa4fe10d81e03ae654c556 /src | |
| parent | d2aad0df601df3a48ee4823309872cd224d91aa3 (diff) | |
| download | go-0f9cdc2fbc8de4ffed049284b1b42c0496d9e05d.tar.xz | |
net/http: use math/rand/v2 instead of math/rand
math/rand/v2 provides a more modern, performant, and secure random number API.
Change-Id: Ic0c30ae40623508e3ed65c435be3c208704b5655
GitHub-Last-Rev: a8fa520b39cb5cc56042b74f6c40163bf8115247
GitHub-Pull-Request: golang/go#76433
Reviewed-on: https://go-review.googlesource.com/c/go/+/723680
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/net/http/server.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/net/http/server.go b/src/net/http/server.go index d63d5bf734..406d2a8407 100644 --- a/src/net/http/server.go +++ b/src/net/http/server.go @@ -17,7 +17,7 @@ import ( "io" "log" "maps" - "math/rand" + "math/rand/v2" "net" "net/textproto" "net/url" @@ -3161,7 +3161,7 @@ func (s *Server) Shutdown(ctx context.Context) error { pollIntervalBase := time.Millisecond nextPollInterval := func() time.Duration { // Add 10% jitter. - interval := pollIntervalBase + time.Duration(rand.Intn(int(pollIntervalBase/10))) + interval := pollIntervalBase + time.Duration(rand.IntN(int(pollIntervalBase/10))) // Double and clamp for next time. pollIntervalBase *= 2 if pollIntervalBase > shutdownPollIntervalMax { |
