Skip to content

Commit 3e55432

Browse files
committed
internal/proxydatasource: support stdlib requests
The proxydatasource now supports requests for stdlib packages. Change-Id: I96e8066c498a2ad9cf518c02f416e9255d5c3954 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/238978 Reviewed-by: Jonathan Amsterdam <[email protected]>
1 parent c6d0ccb commit 3e55432

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

internal/proxydatasource/datasource.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"golang.org/x/pkgsite/internal/licenses"
2424
"golang.org/x/pkgsite/internal/proxy"
2525
"golang.org/x/pkgsite/internal/source"
26+
"golang.org/x/pkgsite/internal/stdlib"
2627
"golang.org/x/pkgsite/internal/version"
2728
)
2829

@@ -240,8 +241,18 @@ func (ds *DataSource) getModule(ctx context.Context, modulePath, version string)
240241
if e, ok := ds.versionCache[key]; ok {
241242
return e.module, e.err
242243
}
243-
244-
res := fetch.FetchModule(ctx, modulePath, version, ds.proxyClient, ds.sourceClient)
244+
v := version
245+
if modulePath == stdlib.ModulePath {
246+
if version == internal.LatestVersion {
247+
// fetch.FetchModule does not support the latest endpoint for the
248+
// standard library, but it is useful to look at these packages when
249+
// developing with the proxydatasource. A hardcoded value is used here,
250+
// so that the request won't fail.
251+
v = "go1.14.4"
252+
}
253+
v = stdlib.VersionForTag(v)
254+
}
255+
res := fetch.FetchModule(ctx, modulePath, v, ds.proxyClient, ds.sourceClient)
245256
m := res.Module
246257
ds.versionCache[key] = &versionEntry{module: m, err: err}
247258
if res.Error != nil {

0 commit comments

Comments
 (0)