From f4bdadf886f3b016bb399240f9337d35eb29e5f0 Mon Sep 17 00:00:00 2001 From: Ethan Lee Date: Wed, 18 Feb 2026 19:21:55 +0000 Subject: frontend: fix loading stdlib in direct_proxy mode - internal/fetch: fix stdlib path extraction by removing invalid "std/" prefix. - internal/fetchdatasource: fix "std" proxy errors in GetLatestInfo. - cmd/frontend: prioritize stdlib getter and add local GOROOT optimization. Reproduction: - `go run ./cmd/frontend -dev -direct_proxy` should utilize the local GOROOT as the source for stdlib. - `go run ./cmd/frontend -direct_proxy` should enable one to via a stdlib library at `localhost:8080/std` or any other stdlib pkg. Fixes golang/go#77112 Change-Id: I0686922804178129550d9bb9edc87b2adff51aa6 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/746700 Auto-Submit: Ethan Lee Reviewed-by: Jonathan Amsterdam kokoro-CI: kokoro Reviewed-by: Nicholas Husin LUCI-TryBot-Result: Go LUCI Reviewed-by: Nicholas Husin --- internal/fetchdatasource/fetchdatasource.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'internal/fetchdatasource/fetchdatasource.go') diff --git a/internal/fetchdatasource/fetchdatasource.go b/internal/fetchdatasource/fetchdatasource.go index f36be0c1..6676d89f 100644 --- a/internal/fetchdatasource/fetchdatasource.go +++ b/internal/fetchdatasource/fetchdatasource.go @@ -23,6 +23,7 @@ import ( "golang.org/x/pkgsite/internal/log" "golang.org/x/pkgsite/internal/lru" "golang.org/x/pkgsite/internal/proxy" + "golang.org/x/pkgsite/internal/stdlib" "golang.org/x/pkgsite/internal/version" ) @@ -285,9 +286,14 @@ func (ds *FetchDataSource) GetLatestInfo(ctx context.Context, unitPath, modulePa latest.MinorVersion = latestUnitMeta.Version latest.MinorModulePath = latestUnitMeta.ModulePath - latest.MajorModulePath, latest.MajorUnitPath, err = ds.getLatestMajorVersion(ctx, unitPath, modulePath) - if err != nil { - return latest, err + if modulePath == stdlib.ModulePath { + latest.MajorModulePath = latest.MinorModulePath + latest.MajorUnitPath = unitPath + } else { + latest.MajorModulePath, latest.MajorUnitPath, err = ds.getLatestMajorVersion(ctx, unitPath, modulePath) + if err != nil { + return latest, err + } } // Do not try to discover whether the unit is in the latest minor version; assume it is. latest.UnitExistsAtMinor = true -- cgit v1.3