}
}
- modload.LoadBuildList()
+ modload.LoadBuildList(ctx)
- mods := modload.ListModules(args, *listU, *listVersions)
+ mods := modload.ListModules(ctx, args, *listU, *listVersions)
if !*listE {
for _, m := range mods {
if m.Error != nil {
var work par.Work
listU := false
listVersions := false
- for _, info := range modload.ListModules(args, listU, listVersions) {
+ for _, info := range modload.ListModules(ctx, args, listU, listVersions) {
if info.Replace != nil {
info = info.Replace
}
base.Fatalf("go: cannot find main module; see 'go help modules'")
}
}
- modload.LoadBuildList()
+ modload.LoadBuildList(ctx)
reqs := modload.MinReqs()
format := func(m module.Version) string {
sem := make(chan token, runtime.GOMAXPROCS(0))
// Use a slice of result channels, so that the output is deterministic.
- mods := modload.LoadBuildList()[1:]
+ mods := modload.LoadBuildList(ctx)[1:]
errsChans := make([]<-chan []error, len(mods))
for i, mod := range mods {
base.Fatalf("go mod why: module query not allowed")
}
}
- mods := modload.ListModules(args, listU, listVersions)
+ mods := modload.ListModules(ctx, args, listU, listVersions)
byModule := make(map[module.Version][]string)
for _, path := range loadALL() {
m := modload.PackageModule(path)
}
modload.LoadTests = *getT
- buildList := modload.LoadBuildList()
+ buildList := modload.LoadBuildList(ctx)
buildList = buildList[:len(buildList):len(buildList)] // copy on append
versionByPath := make(map[string]string)
for _, m := range buildList {
// packages in unknown modules can't be expanded. This also avoids looking
// up new modules while loading packages, only to downgrade later.
queryCache := make(map[querySpec]*query)
- byPath := runQueries(queryCache, queries, nil)
+ byPath := runQueries(ctx, queryCache, queries, nil)
// Add missing modules to the build list.
// We call SetBuildList here and elsewhere, since newUpgrader,
// Query target versions for modules providing packages matched by
// command line arguments.
- byPath = runQueries(queryCache, queries, modOnly)
+ byPath = runQueries(ctx, queryCache, queries, modOnly)
// Handle upgrades. This is needed for arguments that didn't match
// modules or matched different modules from a previous iteration. It
// versions (including earlier queries in the modOnly map), an error will be
// reported. A map from module paths to queries is returned, which includes
// queries and modOnly.
-func runQueries(cache map[querySpec]*query, queries []*query, modOnly map[string]*query) map[string]*query {
+func runQueries(ctx context.Context, cache map[querySpec]*query, queries []*query, modOnly map[string]*query) map[string]*query {
var lookup par.Work
for _, q := range queries {
if cached := cache[q.querySpec]; cached != nil {
package modload
import (
+ "context"
"errors"
"fmt"
"os"
"golang.org/x/mod/module"
)
-func ListModules(args []string, listU, listVersions bool) []*modinfo.ModulePublic {
- mods := listModules(args, listVersions)
+func ListModules(ctx context.Context, args []string, listU, listVersions bool) []*modinfo.ModulePublic {
+ mods := listModules(ctx, args, listVersions)
if listU || listVersions {
var work par.Work
for _, m := range mods {
return mods
}
-func listModules(args []string, listVersions bool) []*modinfo.ModulePublic {
- LoadBuildList()
+func listModules(ctx context.Context, args []string, listVersions bool) []*modinfo.ModulePublic {
+ LoadBuildList(ctx)
if len(args) == 0 {
return []*modinfo.ModulePublic{moduleInfo(buildList[0], true)}
}
import (
"bytes"
- "cmd/go/internal/base"
- "cmd/go/internal/cfg"
- "cmd/go/internal/imports"
- "cmd/go/internal/modfetch"
- "cmd/go/internal/mvs"
- "cmd/go/internal/par"
- "cmd/go/internal/search"
- "cmd/go/internal/str"
+ "context"
"errors"
"fmt"
"go/build"
"sort"
"strings"
+ "cmd/go/internal/base"
+ "cmd/go/internal/cfg"
+ "cmd/go/internal/imports"
+ "cmd/go/internal/modfetch"
+ "cmd/go/internal/mvs"
+ "cmd/go/internal/par"
+ "cmd/go/internal/search"
+ "cmd/go/internal/str"
+ "cmd/go/internal/trace"
+
"golang.org/x/mod/module"
)
// LoadBuildList need only be called if ImportPaths is not
// (typically in commands that care about the module but
// no particular package).
-func LoadBuildList() []module.Version {
+func LoadBuildList(ctx context.Context) []module.Version {
+ ctx, span := trace.StartSpan(ctx, "LoadBuildList")
+ defer span.Done()
InitMod()
ReloadBuildList()
WriteGoMod()