[go] net/http: use math/rand/v2 instead of math/rand

4 views
Skip to first unread message

Gerrit Bot (Gerrit)

unread,
Nov 24, 2025, 7:17:32 AM (9 days ago) Nov 24
to goph...@pubsubhelper.golang.org, 黄志文, golang-co...@googlegroups.com

Gerrit Bot has uploaded the change for review

Commit message

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

Change diff

diff --git a/src/net/http/server.go b/src/net/http/server.go
index d63d5bf..406d2a8 100644
--- a/src/net/http/server.go
+++ b/src/net/http/server.go
@@ -17,7 +17,7 @@
"io"
"log"
"maps"
- "math/rand"
+ "math/rand/v2"
"net"
"net/textproto"
"net/url"
@@ -3161,7 +3161,7 @@
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 {

Change information

Files:
  • M src/net/http/server.go
Change size: XS
Delta: 1 file changed, 2 insertions(+), 2 deletions(-)
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newchange
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: Ic0c30ae40623508e3ed65c435be3c208704b5655
Gerrit-Change-Number: 723680
Gerrit-PatchSet: 1
Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
Gerrit-CC: 黄志文 <alxp...@gmail.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Gopher Robot (Gerrit)

unread,
Nov 24, 2025, 7:17:36 AM (9 days ago) Nov 24
to 黄志文, Gerrit Bot, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Gopher Robot added 1 comment

Patchset-level comments
File-level comment, Patchset 1 (Latest):
Gopher Robot . unresolved

I spotted some possible problems with your PR:

  1. You usually need to reference a bug number for all but trivial or cosmetic fixes. For this repo, the format is usually 'Fixes #12345' or 'Updates #12345' at the end of the commit message. Should you have a bug reference?

Please address any problems by updating the GitHub PR.

When complete, mark this comment as 'Done' and click the [blue 'Reply' button](https://go.dev/wiki/GerritBot#i-left-a-reply-to-a-comment-in-gerrit-but-no-one-but-me-can-see-it) above. These findings are based on heuristics; if a finding does not apply, briefly reply here saying so.

To update the commit title or commit message body shown here in Gerrit, you must edit the GitHub PR title and PR description (the first comment) in the GitHub web interface using the 'Edit' button or 'Edit' menu entry there. Note: pushing a new commit to the PR will not automatically update the commit message used by Gerrit.

For more details, see:

(In general for Gerrit code reviews, the change author is expected to [log in to Gerrit](https://go-review.googlesource.com/login/) with a Gmail or other Google account and then close out each piece of feedback by marking it as 'Done' if implemented as suggested or otherwise reply to each review comment. See the [Review](https://go.dev/doc/contribute#review) section of the Contributing Guide for details.)

Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Ic0c30ae40623508e3ed65c435be3c208704b5655
    Gerrit-Change-Number: 723680
    Gerrit-PatchSet: 1
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-CC: 黄志文 <alxp...@gmail.com>
    Gerrit-Comment-Date: Mon, 24 Nov 2025 12:17:30 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    open
    diffy

    Jorropo (Gerrit)

    unread,
    Nov 24, 2025, 7:55:22 AM (9 days ago) Nov 24
    to 黄志文, Gerrit Bot, goph...@pubsubhelper.golang.org, Damien Neil, Russ Cox, Gopher Robot, golang-co...@googlegroups.com
    Attention needed from Damien Neil

    Jorropo voted Commit-Queue+1

    Commit-Queue+1
    Open in Gerrit

    Related details

    Attention is currently required from:
    • Damien Neil
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Ic0c30ae40623508e3ed65c435be3c208704b5655
    Gerrit-Change-Number: 723680
    Gerrit-PatchSet: 1
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-Reviewer: Damien Neil <dn...@google.com>
    Gerrit-Reviewer: Jorropo <jorro...@gmail.com>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-CC: Russ Cox <r...@golang.org>
    Gerrit-CC: 黄志文 <alxp...@gmail.com>
    Gerrit-Attention: Damien Neil <dn...@google.com>
    Gerrit-Comment-Date: Mon, 24 Nov 2025 12:55:14 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    unsatisfied_requirement
    open
    diffy

    黄志文 (Gerrit)

    unread,
    Nov 24, 2025, 7:57:45 PM (8 days ago) Nov 24
    to Gerrit Bot, goph...@pubsubhelper.golang.org, Go LUCI, Jorropo, Damien Neil, Russ Cox, Gopher Robot, golang-co...@googlegroups.com
    Attention needed from Damien Neil and Jorropo

    黄志文 added 1 comment

    Patchset-level comments
    Gopher Robot . resolved

    I spotted some possible problems with your PR:

      1. You usually need to reference a bug number for all but trivial or cosmetic fixes. For this repo, the format is usually 'Fixes #12345' or 'Updates #12345' at the end of the commit message. Should you have a bug reference?

    Please address any problems by updating the GitHub PR.

    When complete, mark this comment as 'Done' and click the [blue 'Reply' button](https://go.dev/wiki/GerritBot#i-left-a-reply-to-a-comment-in-gerrit-but-no-one-but-me-can-see-it) above. These findings are based on heuristics; if a finding does not apply, briefly reply here saying so.

    To update the commit title or commit message body shown here in Gerrit, you must edit the GitHub PR title and PR description (the first comment) in the GitHub web interface using the 'Edit' button or 'Edit' menu entry there. Note: pushing a new commit to the PR will not automatically update the commit message used by Gerrit.

    For more details, see:

    (In general for Gerrit code reviews, the change author is expected to [log in to Gerrit](https://go-review.googlesource.com/login/) with a Gmail or other Google account and then close out each piece of feedback by marking it as 'Done' if implemented as suggested or otherwise reply to each review comment. See the [Review](https://go.dev/doc/contribute#review) section of the Contributing Guide for details.)

    黄志文

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Damien Neil
    • Jorropo
    Submit Requirements:
      • requirement is not satisfiedCode-Review
      • requirement satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      • requirement is not satisfiedTryBots-Pass
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: go
      Gerrit-Branch: master
      Gerrit-Change-Id: Ic0c30ae40623508e3ed65c435be3c208704b5655
      Gerrit-Change-Number: 723680
      Gerrit-PatchSet: 1
      Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
      Gerrit-Reviewer: Damien Neil <dn...@google.com>
      Gerrit-Reviewer: Jorropo <jorro...@gmail.com>
      Gerrit-CC: Gopher Robot <go...@golang.org>
      Gerrit-CC: Russ Cox <r...@golang.org>
      Gerrit-CC: 黄志文 <alxp...@gmail.com>
      Gerrit-Attention: Jorropo <jorro...@gmail.com>
      Gerrit-Attention: Damien Neil <dn...@google.com>
      Gerrit-Comment-Date: Tue, 25 Nov 2025 00:57:34 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Gopher Robot <go...@golang.org>
      unsatisfied_requirement
      satisfied_requirement
      open
      diffy

      Damien Neil (Gerrit)

      unread,
      Nov 24, 2025, 7:59:01 PM (8 days ago) Nov 24
      to 黄志文, Gerrit Bot, goph...@pubsubhelper.golang.org, Go LUCI, Jorropo, Russ Cox, Gopher Robot, golang-co...@googlegroups.com
      Attention needed from Jorropo

      Damien Neil voted and added 1 comment

      Votes added by Damien Neil

      Auto-Submit+1
      Code-Review+2
      Commit-Queue+1

      1 comment

      Patchset-level comments
      Damien Neil . resolved

      Thanks.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Jorropo
      Submit Requirements:
      • requirement satisfiedCode-Review
      • requirement satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      • requirement is not satisfiedTryBots-Pass
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: go
      Gerrit-Branch: master
      Gerrit-Change-Id: Ic0c30ae40623508e3ed65c435be3c208704b5655
      Gerrit-Change-Number: 723680
      Gerrit-PatchSet: 1
      Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
      Gerrit-Reviewer: Damien Neil <dn...@google.com>
      Gerrit-Reviewer: Jorropo <jorro...@gmail.com>
      Gerrit-CC: Gopher Robot <go...@golang.org>
      Gerrit-CC: Russ Cox <r...@golang.org>
      Gerrit-CC: 黄志文 <alxp...@gmail.com>
      Gerrit-Attention: Jorropo <jorro...@gmail.com>
      Gerrit-Comment-Date: Tue, 25 Nov 2025 00:58:55 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      t hepudds (Gerrit)

      unread,
      Nov 24, 2025, 9:43:47 PM (8 days ago) Nov 24
      to 黄志文, Gerrit Bot, goph...@pubsubhelper.golang.org, Damien Neil, Go LUCI, Jorropo, Russ Cox, Gopher Robot, golang-co...@googlegroups.com
      Attention needed from Damien Neil and Jorropo

      t hepudds voted Commit-Queue+1

      Commit-Queue+1
      Open in Gerrit

      Related details

      Attention is currently required from:
      • Damien Neil
      • Jorropo
      Submit Requirements:
      • requirement satisfiedCode-Review
      • requirement satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      • requirement is not satisfiedTryBots-Pass
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: go
      Gerrit-Branch: master
      Gerrit-Change-Id: Ic0c30ae40623508e3ed65c435be3c208704b5655
      Gerrit-Change-Number: 723680
      Gerrit-PatchSet: 1
      Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
      Gerrit-Reviewer: Damien Neil <dn...@google.com>
      Gerrit-Reviewer: Jorropo <jorro...@gmail.com>
      Gerrit-Reviewer: t hepudds <thepud...@gmail.com>
      Gerrit-CC: Gopher Robot <go...@golang.org>
      Gerrit-CC: Russ Cox <r...@golang.org>
      Gerrit-CC: 黄志文 <alxp...@gmail.com>
      Gerrit-Attention: Jorropo <jorro...@gmail.com>
      Gerrit-Attention: Damien Neil <dn...@google.com>
      Gerrit-Comment-Date: Tue, 25 Nov 2025 02:43:42 +0000
      Gerrit-HasComments: No
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Damien Neil (Gerrit)

      unread,
      Dec 2, 2025, 6:24:07 PM (9 hours ago) Dec 2
      to 黄志文, Gerrit Bot, goph...@pubsubhelper.golang.org, t hepudds, Go LUCI, Jorropo, Russ Cox, Gopher Robot, golang-co...@googlegroups.com
      Attention needed from Jorropo and t hepudds

      Damien Neil voted

      Code-Review+2
      Commit-Queue+1
      Open in Gerrit

      Related details

      Attention is currently required from:
      • Jorropo
      • t hepudds
      Submit Requirements:
      • requirement satisfiedCode-Review
      • requirement satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      • requirement is not satisfiedTryBots-Pass
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: go
      Gerrit-Branch: master
      Gerrit-Change-Id: Ic0c30ae40623508e3ed65c435be3c208704b5655
      Gerrit-Change-Number: 723680
      Gerrit-PatchSet: 2
      Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
      Gerrit-Reviewer: Damien Neil <dn...@google.com>
      Gerrit-Reviewer: Jorropo <jorro...@gmail.com>
      Gerrit-Reviewer: t hepudds <thepud...@gmail.com>
      Gerrit-CC: Gopher Robot <go...@golang.org>
      Gerrit-CC: Russ Cox <r...@golang.org>
      Gerrit-CC: 黄志文 <alxp...@gmail.com>
      Gerrit-Attention: Jorropo <jorro...@gmail.com>
      Gerrit-Attention: t hepudds <thepud...@gmail.com>
      Gerrit-Comment-Date: Tue, 02 Dec 2025 23:24:03 +0000
      Gerrit-HasComments: No
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy
      Reply all
      Reply to author
      Forward
      0 new messages