aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/internal/doc
diff options
context:
space:
mode:
authorqmuntal <quimmuntal@gmail.com>2025-06-27 12:45:22 +0200
committerQuim Muntal <quimmuntal@gmail.com>2025-06-29 07:01:25 -0700
commitacb914f2c2a3ec3dd227812ba6b119480d6400cd (patch)
tree6018c6e80afa0830ee306608e4a2377f8f9739dc /src/cmd/internal/doc
parentb51f1cdb8752c2fdd6a2bf06224aab0b5c07caac (diff)
downloadgo-acb914f2c2a3ec3dd227812ba6b119480d6400cd.tar.xz
cmd/doc: fix -http on Windows
On Windows, GOMODCACHE almost never starts with a slash, and "go doc -http" constructs a GOPROXY URL by doing "file://" + GOMODCACHE, resulting in an invalid file URI. For example, if GOMODCACHE is "C:\foo", then the file URI should be "file:///C:/foo", but it becomes "file://C:/foo" instead, where "C:" is understood as a host name, not a drive letter. Fixes #74137. Change-Id: I23e776e0f649a0062e01d1a4a6ea8268ba467331 Reviewed-on: https://go-review.googlesource.com/c/go/+/684575 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Michael Matloob <matloob@google.com>
Diffstat (limited to 'src/cmd/internal/doc')
-rw-r--r--src/cmd/internal/doc/main.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/cmd/internal/doc/main.go b/src/cmd/internal/doc/main.go
index fe99ee70bd..c51fbef517 100644
--- a/src/cmd/internal/doc/main.go
+++ b/src/cmd/internal/doc/main.go
@@ -227,8 +227,16 @@ func doPkgsite(urlPath string) error {
fields := strings.Fields(vars)
if err == nil && len(fields) == 2 {
goproxy, gomodcache := fields[0], fields[1]
- goproxy = "file://" + filepath.Join(gomodcache, "cache", "download") + "," + goproxy
- env = append(env, "GOPROXY="+goproxy)
+ gomodcache = filepath.Join(gomodcache, "cache", "download")
+ // Convert absolute path to file URL. pkgsite will not accept
+ // Windows absolute paths because they look like a host:path remote.
+ // TODO(golang.org/issue/32456): use url.FromFilePath when implemented.
+ if strings.HasPrefix(gomodcache, "/") {
+ gomodcache = "file://" + gomodcache
+ } else {
+ gomodcache = "file:///" + filepath.ToSlash(gomodcache)
+ }
+ env = append(env, "GOPROXY="+gomodcache+","+goproxy)
}
const version = "v0.0.0-20250608123103-82c52f1754cd"