Skip to content

Commit 6d087c8

Browse files
author
Bryan C. Mills
committed
cmd/go/internal/modload: handle NotExist errors in (*mvsReqs).Previous
Previous is used during downgrading. If the module proxy does not advertise any versions (for example, because it contains only pseudo-versions), then Previous should return "none" instead of a non-nil error. For #37438 Change-Id: I4edfec19cfeb3ffe50df4979f99a01321c442509 Reviewed-on: https://go-review.googlesource.com/c/go/+/266370 Trust: Bryan C. Mills <[email protected]> Run-TryBot: Bryan C. Mills <[email protected]> Reviewed-by: Jay Conrod <[email protected]> Reviewed-by: Michael Matloob <[email protected]> TryBot-Result: Go Bot <[email protected]>
1 parent 8494a62 commit 6d087c8

File tree

1 file changed

+4
-0
lines changed
  • src/cmd/go/internal/modload

1 file changed

+4
-0
lines changed

src/cmd/go/internal/modload/mvs.go

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package modload
77
import (
88
"context"
99
"errors"
10+
"os"
1011
"sort"
1112

1213
"cmd/go/internal/modfetch"
@@ -102,6 +103,9 @@ func (*mvsReqs) Previous(m module.Version) (module.Version, error) {
102103
// TODO(golang.org/issue/38714): thread tracing context through MVS.
103104
list, err := versions(context.TODO(), m.Path, CheckAllowed)
104105
if err != nil {
106+
if errors.Is(err, os.ErrNotExist) {
107+
return module.Version{Path: m.Path, Version: "none"}, nil
108+
}
105109
return module.Version{}, err
106110
}
107111
i := sort.Search(len(list), func(i int) bool { return semver.Compare(list[i], m.Version) >= 0 })

0 commit comments

Comments
 (0)