diff options
| author | Ethan Lee <ethanalee@google.com> | 2026-02-18 19:21:55 +0000 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2026-02-23 09:51:15 -0800 |
| commit | f4bdadf886f3b016bb399240f9337d35eb29e5f0 (patch) | |
| tree | 6494158973ff1892f8b4e2e3dca31ff85a3aa9aa /internal/fetchdatasource/fetchdatasource.go | |
| parent | bf658f25df2c830b76166ce77350f62e90834365 (diff) | |
| download | go-x-pkgsite-f4bdadf886f3b016bb399240f9337d35eb29e5f0.tar.xz | |
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 <ethanalee@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
kokoro-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Nicholas Husin <husin@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Nicholas Husin <nsh@golang.org>
Diffstat (limited to 'internal/fetchdatasource/fetchdatasource.go')
| -rw-r--r-- | internal/fetchdatasource/fetchdatasource.go | 12 |
1 files changed, 9 insertions, 3 deletions
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 |
