Commit 54b7afb4 authored by Bryan C. Mills's avatar Bryan C. Mills

cmd/go/internal/modfetch: reduce path redundancy in checkMod error reporting

Updates #30748

Change-Id: I38a6cdc9c9b488fec579e6362a4284e26e0f526e
Reviewed-on: https://go-review.googlesource.com/c/go/+/189782
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarJay Conrod <jayconrod@google.com>
parent 3d522b10
...@@ -7,6 +7,7 @@ package modfetch ...@@ -7,6 +7,7 @@ package modfetch
import ( import (
"archive/zip" "archive/zip"
"bytes" "bytes"
"errors"
"fmt" "fmt"
"io" "io"
"io/ioutil" "io/ioutil"
...@@ -361,19 +362,19 @@ func checkMod(mod module.Version) { ...@@ -361,19 +362,19 @@ func checkMod(mod module.Version) {
// Do the file I/O before acquiring the go.sum lock. // Do the file I/O before acquiring the go.sum lock.
ziphash, err := CachePath(mod, "ziphash") ziphash, err := CachePath(mod, "ziphash")
if err != nil { if err != nil {
base.Fatalf("verifying %s@%s: %v", mod.Path, mod.Version, err) base.Fatalf("verifying %v", module.VersionError(mod, err))
} }
data, err := renameio.ReadFile(ziphash) data, err := renameio.ReadFile(ziphash)
if err != nil { if err != nil {
if os.IsNotExist(err) { if errors.Is(err, os.ErrNotExist) {
// This can happen if someone does rm -rf GOPATH/src/cache/download. So it goes. // This can happen if someone does rm -rf GOPATH/src/cache/download. So it goes.
return return
} }
base.Fatalf("verifying %s@%s: %v", mod.Path, mod.Version, err) base.Fatalf("verifying %v", module.VersionError(mod, err))
} }
h := strings.TrimSpace(string(data)) h := strings.TrimSpace(string(data))
if !strings.HasPrefix(h, "h1:") { if !strings.HasPrefix(h, "h1:") {
base.Fatalf("verifying %s@%s: unexpected ziphash: %q", mod.Path, mod.Version, h) base.Fatalf("verifying %v", module.VersionError(mod, fmt.Errorf("unexpected ziphash: %q", h)))
} }
checkModSum(mod, h) checkModSum(mod, h)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment