diff options
author | Jay Conrod <jayconrod@google.com> | 2020-10-13 18:19:21 -0400 |
---|---|---|
committer | Jay Conrod <jayconrod@google.com> | 2020-10-23 20:54:30 +0000 |
commit | 5cd4390f3853b8d0d2d962f7acdac87c0eba3d77 (patch) | |
tree | 52079404d9c5b294a88c8bfe5ff5b0cc56d581ad /src/cmd/go/internal/modload/load.go | |
parent | 5f616a6fe789622f3e0ed0e8a00db9471e2a02f4 (diff) | |
download | go-5cd4390f3853b8d0d2d962f7acdac87c0eba3d77.tar.gz go-5cd4390f3853b8d0d2d962f7acdac87c0eba3d77.zip |
cmd/go: don't fetch files missing sums in readonly mode
If the go command needs a .mod or .zip file in -mod=readonly mode
(now the default), and that file doesn't have a hash in the main
module's go.sum file, the go command will now report an error before
fetching the file, rather than at the end when failing to update
go.sum. The error says specifically which entry is missing.
If this error is encountered when loading the build list, it will
suggest 'go mod tidy'.
If this error is encountered when loading a specific package (an
import or command line argument), the error will mention that package
and will suggest 'go mod tidy' or 'go get -d'.
Fixes #41934
Fixes #41935
Change-Id: I96ec2ef9258bd4bade9915c43d47e6243c376a81
Reviewed-on: https://go-review.googlesource.com/c/go/+/262341
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Trust: Jay Conrod <jayconrod@google.com>
Diffstat (limited to 'src/cmd/go/internal/modload/load.go')
-rw-r--r-- | src/cmd/go/internal/modload/load.go | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/cmd/go/internal/modload/load.go b/src/cmd/go/internal/modload/load.go index dc816540b9..b770c19c7c 100644 --- a/src/cmd/go/internal/modload/load.go +++ b/src/cmd/go/internal/modload/load.go @@ -276,6 +276,8 @@ func LoadPackages(ctx context.Context, opts PackageOpts, patterns ...string) (ma if pkg.flags.has(pkgInAll) { if imErr := (*ImportMissingError)(nil); errors.As(pkg.err, &imErr) { imErr.inAll = true + } else if sumErr := (*ImportMissingSumError)(nil); errors.As(pkg.err, &sumErr) { + sumErr.inAll = true } } |