internal/fetch: don't fetch raw latest for std

The proxy fails on std/@v/list, so don't query it about the raw latest
version of the stdlib.  Don't track it at all, in fact, on the
assumption that the stdlib will never be deprecated or have
retractions.

Change-Id: I49bf6f29b87ec036a344022f5a9103b5d34bacd1
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/296816
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Julie Qiu <julie@golang.org>
diff --git a/internal/fetch/raw_latest.go b/internal/fetch/raw_latest.go
index b5f69e1..46fe492 100644
--- a/internal/fetch/raw_latest.go
+++ b/internal/fetch/raw_latest.go
@@ -12,11 +12,12 @@
 	"golang.org/x/pkgsite/internal/derrors"
 	"golang.org/x/pkgsite/internal/log"
 	"golang.org/x/pkgsite/internal/proxy"
+	"golang.org/x/pkgsite/internal/stdlib"
 	"golang.org/x/pkgsite/internal/version"
 )
 
 // RawLatestInfo uses the proxy to get information about the raw latest version
-// of modulePath.
+// of modulePath. If it cannot obtain it, it returns (nil, nil).
 //
 // The hasGoMod function that is passed in should check if version v of the
 // module has a go.mod file, using a source other than the proxy (e.g. a
@@ -25,6 +26,11 @@
 func RawLatestInfo(ctx context.Context, modulePath string, prox *proxy.Client, hasGoMod func(v string) (bool, error)) (_ *internal.RawLatestInfo, err error) {
 	defer derrors.WrapStack(&err, "RawLatestInfo(%q)", modulePath)
 
+	// No raw latest info for std; no deprecations or retractions.
+	if modulePath == stdlib.ModulePath {
+		return nil, nil
+	}
+
 	v, err := fetchRawLatestVersion(ctx, modulePath, prox, hasGoMod)
 	if err != nil {
 		return nil, err
diff --git a/internal/raw_latest.go b/internal/raw_latest.go
index 28d6168..eb9c20c 100644
--- a/internal/raw_latest.go
+++ b/internal/raw_latest.go
@@ -41,6 +41,9 @@
 
 // PopulateModuleInfo uses the RawLatestInfo to populate fields of the given module.
 func (r *RawLatestInfo) PopulateModuleInfo(mi *ModuleInfo) {
+	if r == nil {
+		return
+	}
 	mi.Deprecated = r.deprecated
 	mi.DeprecationComment = r.deprecationComment
 	mi.Retracted, mi.RetractionRationale = isRetracted(r.GoModFile, mi.Version)
diff --git a/internal/worker/fetch.go b/internal/worker/fetch.go
index 4a71dd0..0909aea 100644
--- a/internal/worker/fetch.go
+++ b/internal/worker/fetch.go
@@ -404,5 +404,9 @@
 	if err != nil {
 		return err
 	}
+	if info == nil {
+		// No info (e.g. for stdlib); that's fine.
+		return nil
+	}
 	return f.DB.UpdateRawLatestInfo(ctx, info)
 }