From: Russ Cox Date: Wed, 5 Nov 2025 19:46:35 +0000 (-0500) Subject: cmd/go: fix TestScript/govcs X-Git-Tag: go1.26rc1~362 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=28f1ad5782d80a0a3f95b004c6a822003fd0b1a1;p=gostls13.git 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 --- 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)