retain = append(retain, m.Path)
}
}
- min, err := mvs.Req(Target, retain, Reqs())
+ min, err := mvs.Req(Target, retain, &mvsReqs{buildList: buildList})
if err != nil {
base.Fatalf("go: %v", err)
}
keep := make(map[module.Version]bool)
var mu sync.Mutex
reqs := &keepSumReqs{
- Reqs: Reqs(),
+ Reqs: &mvsReqs{buildList: buildList},
visit: func(m module.Version) {
// If we build using a replacement module, keep the sum for the replacement,
// since that's the code we'll actually use during a build.
}
var err error
- reqs := Reqs()
+ reqs := &mvsReqs{buildList: buildList}
buildList, err = mvs.BuildList(Target, reqs)
if err != nil {
base.Fatalf("go: %v", err)
}
// Recompute buildList with all our additions.
- reqs = Reqs()
+ reqs = &mvsReqs{buildList: buildList}
buildList, err = mvs.BuildList(Target, reqs)
if err != nil {
// If an error was found in a newly added module, report the package
"sort"
"cmd/go/internal/modfetch"
- "cmd/go/internal/mvs"
"golang.org/x/mod/module"
"golang.org/x/mod/semver"
buildList []module.Version
}
-// Reqs returns the current module requirement graph.
-// Future calls to EditBuildList do not affect the operation
-// of the returned Reqs.
-func Reqs() mvs.Reqs {
- r := &mvsReqs{
- buildList: buildList,
- }
- return r
-}
-
func (r *mvsReqs) Required(mod module.Version) ([]module.Version, error) {
if mod == Target {
// Use the build list as it existed when r was constructed, not the current
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package modload_test
+package modload
import (
"testing"
-
- "cmd/go/internal/modload"
)
func TestReqsMax(t *testing.T) {
type testCase struct {
a, b, want string
}
- reqs := modload.Reqs()
+ reqs := new(mvsReqs)
for _, tc := range []testCase{
{a: "v0.1.0", b: "v0.2.0", want: "v0.2.0"},
{a: "v0.2.0", b: "v0.1.0", want: "v0.2.0"},
} {
max := reqs.Max(tc.a, tc.b)
if max != tc.want {
- t.Errorf("Reqs().Max(%q, %q) = %q; want %q", tc.a, tc.b, max, tc.want)
+ t.Errorf("(%T).Max(%q, %q) = %q; want %q", reqs, tc.a, tc.b, max, tc.want)
}
}
}