From 28f1ad5782d80a0a3f95b004c6a822003fd0b1a1 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 5 Nov 2025 14:46:35 -0500 Subject: [PATCH] cmd/go: fix TestScript/govcs On my Mac, TestScript/govcs was failing because hg prints a URL using 1.0.0.127.in-addr.arpa instead of 127.0.0.1, and my Mac cannot resolve that name back into an IP address. % host 127.0.0.1 1.0.0.127.in-addr.arpa domain name pointer localhost. % host 1.0.0.127.in-addr.arpa % Change-Id: Ia0762342d5926d13d786fe66de40590dc8977ff5 Reviewed-on: https://go-review.googlesource.com/c/go/+/718184 Reviewed-by: Michael Matloob Reviewed-by: Michael Matloob Auto-Submit: Russ Cox LUCI-TryBot-Result: Go LUCI --- src/cmd/go/internal/vcweb/hg.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/cmd/go/internal/vcweb/hg.go b/src/cmd/go/internal/vcweb/hg.go index 4571277c9f..e07cd3c875 100644 --- a/src/cmd/go/internal/vcweb/hg.go +++ b/src/cmd/go/internal/vcweb/hg.go @@ -109,6 +109,13 @@ func (h *hgHandler) Handler(dir string, env []string, logger *log.Logger) (http. wg.Done() }() + // On some systems, + // hg serve --address=localhost --print-url prints in-addr.arpa hostnames + // even though they cannot be looked up. + // Replace them with IP literals. + line = strings.ReplaceAll(line, "//1.0.0.127.in-addr.arpa", "//127.0.0.1") + line = strings.ReplaceAll(line, "//1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa", "//[::1]") + u, err := url.Parse(strings.TrimSpace(line)) if err != nil { logger.Printf("%v: %v", cmd, err) -- 2.52.0