[go] cmd/trace: rewrite unspecified address to localhost in URL

0 views
Skip to first unread message

Michael Pratt (Gerrit)

unread,
Apr 24, 2026, 4:09:28 PM (17 hours ago) Apr 24
to Michael Pratt, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, golang...@luci-project-accounts.iam.gserviceaccount.com, Damien Neil, Carlos Amedee, Michael Knyszek, golang-co...@googlegroups.com

Michael Pratt submitted the change

Change information

Commit message:
cmd/trace: rewrite unspecified address to localhost in URL

The previous CL makes -http=:6060 listen on localhost instead of all
addresses, so this case will print http://127.0.0.1:6060.

However, when user explicitly pass the unspecified address (e.g.,
-http=0.0.0.0:6060), we will print http://0.0.0.0:6060.

Clicking this link to connect unspecified address doesn't make much
sense. On Linux, the kernel happens to treat connect to the unspecified
address as a connect to loopback, so this works fine. On the other hand,
Windows treats connect to the unspecified address as an explicit error,
so this URL doesn't work.

Instead, rewrite the unspecified address to localhost when printing the
URL to ensure it works on all OSes. To avoid hiding that we are
listening all addresses, we now print the full listen address in
addition to the potentially rewritten URL.

Fixes #78921.
Change-Id: If99d5126c13059aa58c870dcc52476716a6a6964
Reviewed-by: Damien Neil <dn...@google.com>
Files:
  • M src/cmd/trace/main.go
  • M src/cmd/trace/main_test.go
Change size: M
Delta: 2 files changed, 110 insertions(+), 1 deletion(-)
Branch: refs/heads/master
Submit Requirements:
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: If99d5126c13059aa58c870dcc52476716a6a6964
Gerrit-Change-Number: 770462
Gerrit-PatchSet: 4
Gerrit-Owner: Michael Pratt <mpr...@google.com>
Gerrit-Reviewer: Carlos Amedee <car...@golang.org>
Gerrit-Reviewer: Damien Neil <dn...@google.com>
Gerrit-Reviewer: Michael Pratt <mpr...@google.com>
Gerrit-CC: Michael Knyszek <mkny...@google.com>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages