[go] Fix removeEmptyPort

2 views
Skip to first unread message

Gerrit Bot (Gerrit)

unread,
Dec 1, 2025, 11:26:23 PM (2 days ago) Dec 1
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Gerrit Bot has uploaded the change for review

Commit message

Fix removeEmptyPort

remove hasPort and simplify logic

#76651
Change-Id: I753337d96d04b3ba45da3d7895bb34c07214fb11
GitHub-Last-Rev: 770502aad811cf5524a00bf60d4dd35a2d22e063
GitHub-Pull-Request: golang/go#76652

Change diff

diff --git a/src/net/http/http.go b/src/net/http/http.go
index d346e60..c7a7901 100644
--- a/src/net/http/http.go
+++ b/src/net/http/http.go
@@ -113,8 +113,8 @@
// removeEmptyPort strips the empty port in ":port" to ""
// as mandated by RFC 3986 Section 6.2.3.
func removeEmptyPort(host string) string {
- if hasPort(host) {
- return strings.TrimSuffix(host, ":")
+ if len(host) > 0 && host[len(host)-1] == ':' {
+ return host[:len(host)-1]
}
return host
}

Change information

Files:
  • M src/net/http/http.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: I753337d96d04b3ba45da3d7895bb34c07214fb11
Gerrit-Change-Number: 725605
Gerrit-PatchSet: 1
Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Gopher Robot (Gerrit)

unread,
Dec 1, 2025, 11:26:25 PM (2 days ago) Dec 1
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. The commit title should start with the primary affected package name followed by a colon, like "net/http: improve [...]".
2. The first word in the commit title after the package should be a lowercase English word (usually a verb).

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: I753337d96d04b3ba45da3d7895bb34c07214fb11
    Gerrit-Change-Number: 725605
    Gerrit-PatchSet: 1
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-Comment-Date: Tue, 02 Dec 2025 04:26:20 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    open
    diffy

    Ian Lance Taylor (Gerrit)

    unread,
    Dec 1, 2025, 11:48:15 PM (2 days ago) Dec 1
    to Gerrit Bot, goph...@pubsubhelper.golang.org, Ian Lance Taylor, Gopher Robot, golang-co...@googlegroups.com

    Ian Lance Taylor added 1 comment

    File src/net/http/http.go
    Line 116, Patchset 1 (Latest): if len(host) > 0 && host[len(host)-1] == ':' {
    Ian Lance Taylor . unresolved

    Thanks. This will be clearer and simpler using strings.CutSuffix.

    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: I753337d96d04b3ba45da3d7895bb34c07214fb11
    Gerrit-Change-Number: 725605
    Gerrit-PatchSet: 1
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-CC: Ian Lance Taylor <ia...@golang.org>
    Gerrit-Comment-Date: Tue, 02 Dec 2025 04:48:07 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    open
    diffy

    Gerrit Bot (Gerrit)

    unread,
    Dec 2, 2025, 1:26:33 AM (yesterday) Dec 2
    to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
    Attention needed from Damien Neil

    Gerrit Bot uploaded new patchset

    Gerrit Bot uploaded patch set #2 to this change.
    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: newpatchset
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I753337d96d04b3ba45da3d7895bb34c07214fb11
    Gerrit-Change-Number: 725605
    Gerrit-PatchSet: 2
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-Reviewer: Damien Neil <dn...@google.com>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-CC: Ian Lance Taylor <ia...@golang.org>
    Gerrit-CC: Russ Cox <r...@golang.org>
    Gerrit-Attention: Damien Neil <dn...@google.com>
    unsatisfied_requirement
    open
    diffy

    sz dxasu (Gerrit)

    unread,
    Dec 2, 2025, 2:41:42 AM (yesterday) Dec 2
    to Gerrit Bot, goph...@pubsubhelper.golang.org, Damien Neil, Russ Cox, Ian Lance Taylor, Gopher Robot, golang-co...@googlegroups.com
    Attention needed from Damien Neil and Ian Lance Taylor

    sz dxasu added 2 comments

    Patchset-level comments
    File-level comment, Patchset 1:
    Gopher Robot . resolved

    I spotted some possible problems with your PR:

      1. The commit title should start with the primary affected package name followed by a colon, like "net/http: improve [...]".
    2. The first word in the commit title after the package should be a lowercase English word (usually a verb).

    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.)

    sz dxasu

    Done

    File src/net/http/http.go
    Line 116, Patchset 1: if len(host) > 0 && host[len(host)-1] == ':' {
    Ian Lance Taylor . resolved

    Thanks. This will be clearer and simpler using strings.CutSuffix.

    sz dxasu

    Acknowledged

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Damien Neil
    • Ian Lance Taylor
    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: I753337d96d04b3ba45da3d7895bb34c07214fb11
      Gerrit-Change-Number: 725605
      Gerrit-PatchSet: 2
      Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
      Gerrit-Reviewer: Damien Neil <dn...@google.com>
      Gerrit-CC: Gopher Robot <go...@golang.org>
      Gerrit-CC: Ian Lance Taylor <ia...@golang.org>
      Gerrit-CC: Russ Cox <r...@golang.org>
      Gerrit-CC: sz dxasu <lvz...@gmail.com>
      Gerrit-Attention: Ian Lance Taylor <ia...@golang.org>
      Gerrit-Attention: Damien Neil <dn...@google.com>
      Gerrit-Comment-Date: Tue, 02 Dec 2025 07:41:34 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Ian Lance Taylor <ia...@golang.org>
      Comment-In-Reply-To: Gopher Robot <go...@golang.org>
      unsatisfied_requirement
      satisfied_requirement
      open
      diffy

      Damien Neil (Gerrit)

      unread,
      Dec 2, 2025, 6:14:44 PM (10 hours ago) Dec 2
      to Gerrit Bot, goph...@pubsubhelper.golang.org, Jorropo, Dmitri Shuralyov, sz dxasu, Russ Cox, Ian Lance Taylor, Gopher Robot, golang-co...@googlegroups.com
      Attention needed from Ian Lance Taylor

      Damien Neil added 3 comments

      Patchset-level comments
      File-level comment, Patchset 2 (Latest):
      Damien Neil . resolved

      Thanks.

      Commit Message
      Line 11, Patchset 2 (Latest):#76651
      Damien Neil . unresolved

      ```
      net/http: simplify removeEmptyPort

      Fixes #76651
      ```

      All CLs should have a summary line beginning with the affected package(s).

      The "Fixes #XXX" syntax is understood by gopherbot and used to associate CLs with issues.

      File src/net/http/http.go
      Line 116, Patchset 2 (Latest): host, _ = strings.CutSuffix(host, ":")
      Damien Neil . unresolved

      Why not `return strings.TrimSuffix(host, ":")`?

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Ian Lance Taylor
      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: I753337d96d04b3ba45da3d7895bb34c07214fb11
        Gerrit-Change-Number: 725605
        Gerrit-PatchSet: 2
        Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
        Gerrit-Reviewer: Damien Neil <dn...@google.com>
        Gerrit-CC: Dmitri Shuralyov <dmit...@google.com>
        Gerrit-CC: Gopher Robot <go...@golang.org>
        Gerrit-CC: Ian Lance Taylor <ia...@golang.org>
        Gerrit-CC: Jorropo <jorro...@gmail.com>
        Gerrit-CC: Russ Cox <r...@golang.org>
        Gerrit-CC: sz dxasu <lvz...@gmail.com>
        Gerrit-Attention: Ian Lance Taylor <ia...@golang.org>
        Gerrit-Comment-Date: Tue, 02 Dec 2025 23:14:38 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        unsatisfied_requirement
        open
        diffy

        Damien Neil (Gerrit)

        unread,
        Dec 2, 2025, 6:23:14 PM (9 hours ago) Dec 2
        to Gerrit Bot, goph...@pubsubhelper.golang.org, Jorropo, Dmitri Shuralyov, sz dxasu, Russ Cox, Ian Lance Taylor, Gopher Robot, golang-co...@googlegroups.com
        Attention needed from Ian Lance Taylor

        Damien Neil added 1 comment

        Patchset-level comments
        Damien Neil . unresolved

        By the way, I just noticed that this CL and https://go.dev/cl/725740 are both cleaning up the same code.

        CL 725740 does a bit more and was created first (although only by 20 minutes), so perhaps we should go with that one.

        Gerrit-Comment-Date: Tue, 02 Dec 2025 23:23:09 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        unsatisfied_requirement
        open
        diffy

        Gerrit Bot (Gerrit)

        unread,
        Dec 2, 2025, 9:12:28 PM (7 hours ago) Dec 2
        to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
        Attention needed from Damien Neil and Ian Lance Taylor

        Gerrit Bot uploaded new patchset

        Gerrit Bot uploaded patch set #3 to this change.
        Open in Gerrit

        Related details

        Attention is currently required from:
        • Damien Neil
        • Ian Lance Taylor
        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: newpatchset
        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: I753337d96d04b3ba45da3d7895bb34c07214fb11
        Gerrit-Change-Number: 725605
        Gerrit-PatchSet: 3
        Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
        Gerrit-Reviewer: Damien Neil <dn...@google.com>
        Gerrit-CC: Dmitri Shuralyov <dmit...@google.com>
        Gerrit-CC: Gopher Robot <go...@golang.org>
        Gerrit-CC: Ian Lance Taylor <ia...@golang.org>
        Gerrit-CC: Jorropo <jorro...@gmail.com>
        Gerrit-CC: Russ Cox <r...@golang.org>
        Gerrit-CC: sz dxasu <lvz...@gmail.com>
        Gerrit-Attention: Ian Lance Taylor <ia...@golang.org>
        Gerrit-Attention: Damien Neil <dn...@google.com>
        unsatisfied_requirement
        open
        diffy

        sz dxasu (Gerrit)

        unread,
        Dec 2, 2025, 9:15:23 PM (6 hours ago) Dec 2
        to Gerrit Bot, goph...@pubsubhelper.golang.org, Jorropo, Dmitri Shuralyov, Damien Neil, Russ Cox, Ian Lance Taylor, Gopher Robot, golang-co...@googlegroups.com
        Attention needed from Damien Neil and Ian Lance Taylor

        sz dxasu added 2 comments

        Commit Message
        Line 11, Patchset 2:#76651
        Damien Neil . resolved

        ```
        net/http: simplify removeEmptyPort

        Fixes #76651
        ```

        All CLs should have a summary line beginning with the affected package(s).

        The "Fixes #XXX" syntax is understood by gopherbot and used to associate CLs with issues.

        sz dxasu

        Done

        File src/net/http/http.go
        Line 116, Patchset 2: host, _ = strings.CutSuffix(host, ":")
        Damien Neil . resolved

        Why not `return strings.TrimSuffix(host, ":")`?

        sz dxasu

        You are right

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Damien Neil
        • Ian Lance Taylor
        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: I753337d96d04b3ba45da3d7895bb34c07214fb11
        Gerrit-Change-Number: 725605
        Gerrit-PatchSet: 2
        Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
        Gerrit-Reviewer: Damien Neil <dn...@google.com>
        Gerrit-CC: Dmitri Shuralyov <dmit...@google.com>
        Gerrit-CC: Gopher Robot <go...@golang.org>
        Gerrit-CC: Ian Lance Taylor <ia...@golang.org>
        Gerrit-CC: Jorropo <jorro...@gmail.com>
        Gerrit-CC: Russ Cox <r...@golang.org>
        Gerrit-CC: sz dxasu <lvz...@gmail.com>
        Gerrit-Attention: Ian Lance Taylor <ia...@golang.org>
        Gerrit-Attention: Damien Neil <dn...@google.com>
        Gerrit-Comment-Date: Wed, 03 Dec 2025 02:15:16 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        Comment-In-Reply-To: Damien Neil <dn...@google.com>
        unsatisfied_requirement
        open
        diffy

        Gerrit Bot (Gerrit)

        unread,
        Dec 2, 2025, 9:21:15 PM (6 hours ago) Dec 2
        to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
        Attention needed from Damien Neil and Ian Lance Taylor

        Gerrit Bot uploaded new patchset

        Gerrit Bot uploaded patch set #4 to this change.
        Open in Gerrit

        Related details

        Attention is currently required from:
        • Damien Neil
        • Ian Lance Taylor
        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: newpatchset
        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: I753337d96d04b3ba45da3d7895bb34c07214fb11
        Gerrit-Change-Number: 725605
        Gerrit-PatchSet: 4
        unsatisfied_requirement
        open
        diffy
        Reply all
        Reply to author
        Forward
        0 new messages