Commit d346a9b7 authored by Leon Klingele's avatar Leon Klingele Committed by Bryan C. Mills

cmd/go/internal/modfetch: add missing error checks

Change-Id: I51a9c06384875fbb12db0e05128f23bd23a163a1
GitHub-Last-Rev: 126452f15cbb8e06ff683dcd60e63f1925dcf8f1
GitHub-Pull-Request: golang/go#30000
Reviewed-on: https://go-review.googlesource.com/c/160424Reviewed-by: default avatarBryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent acf8f2c1
......@@ -541,6 +541,9 @@ func (r *codeRepo) Zip(dst io.Writer, version string) error {
return err
}
w, err := zw.Create(r.modPrefix(version) + "/" + name)
if err != nil {
return err
}
lr := &io.LimitedReader{R: rc, N: size + 1}
if _, err := io.Copy(w, lr); err != nil {
return err
......
......@@ -98,6 +98,9 @@ func IsPseudoVersion(v string) bool {
// embedded in the pseudo-version is not a valid time.
func PseudoVersionTime(v string) (time.Time, error) {
timestamp, _, err := parsePseudoVersion(v)
if err != nil {
return time.Time{}, err
}
t, err := time.Parse("20060102150405", timestamp)
if err != nil {
return time.Time{}, fmt.Errorf("pseudo-version with malformed time %s: %q", timestamp, v)
......
......@@ -60,6 +60,13 @@ func TestPseudoVersionTime(t *testing.T) {
}
}
func TestInvalidPseudoVersionTime(t *testing.T) {
const v = "---"
if _, err := PseudoVersionTime(v); err == nil {
t.Error("expected error, got nil instead")
}
}
func TestPseudoVersionRev(t *testing.T) {
for _, tt := range pseudoTests {
rev, err := PseudoVersionRev(tt.version)
......
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