From 31fd60d6bfdcfb2861856aa5b333bb135f6bbfd8 Mon Sep 17 00:00:00 2001 From: Jay Conrod Date: Thu, 25 Apr 2019 12:07:40 -0400 Subject: [PATCH] x/tools/go/packages/packagestest: fix GOPROXY file URLs for Windows On Windows, file URLs should look like file:///C:/foo/bar instead of file://C:/foo/bar. In the latter case, the "C:" is parsed as the host. Updates golang/go#31675 Change-Id: I7f75be44dd5d289de3ffdbd20a78130ed03cd233 Reviewed-on: https://go-review.googlesource.com/c/tools/+/173918 Run-TryBot: Jay Conrod Reviewed-by: Ian Cottrell --- go/packages/packagestest/modules.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/go/packages/packagestest/modules.go b/go/packages/packagestest/modules.go index 0bcdbf5c84a..1ca961a9cd8 100644 --- a/go/packages/packagestest/modules.go +++ b/go/packages/packagestest/modules.go @@ -14,6 +14,7 @@ import ( "path" "path/filepath" "regexp" + "strings" "golang.org/x/tools/go/packages" ) @@ -101,6 +102,13 @@ func (modules) Finalize(exported *Exported) error { return fmt.Errorf("creating module proxy dir for %v: %v", module, err) } } + proxyURL := filepath.ToSlash(proxyDir) + if !strings.HasPrefix(proxyURL, "/") { + // Windows paths will look like C:/foo/bar. In the URL, the C: will be + // interpreted as the host, so add a leading /. See golang.org/issue/6027. + proxyURL = "/" + proxyURL + } + proxyURL = "file://" + proxyURL // Discard the original mod cache dir, which contained the files written // for us by Export.