@@ -118,22 +118,10 @@ import (
118
118
"cmd/go/internal/par"
119
119
"cmd/go/internal/search"
120
120
"cmd/go/internal/str"
121
- "cmd/go/internal/trace"
122
121
123
122
"golang.org/x/mod/module"
124
123
)
125
124
126
- // buildList is the list of modules to use for building packages.
127
- // It is initialized by calling ImportPaths, ImportFromFiles,
128
- // LoadALL, or LoadBuildList, each of which uses loaded.load.
129
- //
130
- // Ideally, exactly ONE of those functions would be called,
131
- // and exactly once. Most of the time, that's true.
132
- // During "go get" it may not be. TODO(rsc): Figure out if
133
- // that restriction can be established, or else document why not.
134
- //
135
- var buildList []module.Version
136
-
137
125
// loaded is the most recently-used package loader.
138
126
// It holds details about individual packages.
139
127
var loaded * loader
@@ -250,26 +238,6 @@ func ImportPathsQuiet(ctx context.Context, patterns []string, tags map[string]bo
250
238
return matches
251
239
}
252
240
253
- // checkMultiplePaths verifies that a given module path is used as itself
254
- // or as a replacement for another module, but not both at the same time.
255
- //
256
- // (See https://golang.org/issue/26607 and https://golang.org/issue/34650.)
257
- func checkMultiplePaths () {
258
- firstPath := make (map [module.Version ]string , len (buildList ))
259
- for _ , mod := range buildList {
260
- src := mod
261
- if rep := Replacement (mod ); rep .Path != "" {
262
- src = rep
263
- }
264
- if prev , ok := firstPath [src ]; ! ok {
265
- firstPath [src ] = mod .Path
266
- } else if prev != mod .Path {
267
- base .Errorf ("go: %s@%s used for two different module paths (%s and %s)" , src .Path , src .Version , prev , mod .Path )
268
- }
269
- }
270
- base .ExitIfErrors ()
271
- }
272
-
273
241
// matchLocalDirs is like m.MatchDirs, but tries to avoid scanning directories
274
242
// outside of the standard library and active modules.
275
243
func matchLocalDirs (m * search.Match ) {
@@ -481,31 +449,6 @@ func DirImportPath(dir string) string {
481
449
return "."
482
450
}
483
451
484
- // LoadBuildList loads and returns the build list from go.mod.
485
- // The loading of the build list happens automatically in ImportPaths:
486
- // LoadBuildList need only be called if ImportPaths is not
487
- // (typically in commands that care about the module but
488
- // no particular package).
489
- func LoadBuildList (ctx context.Context ) []module.Version {
490
- ctx , span := trace .StartSpan (ctx , "LoadBuildList" )
491
- defer span .Done ()
492
- InitMod (ctx )
493
- ReloadBuildList ()
494
- WriteGoMod ()
495
- return buildList
496
- }
497
-
498
- // ReloadBuildList resets the state of loaded packages, then loads and returns
499
- // the build list set in SetBuildList.
500
- func ReloadBuildList () []module.Version {
501
- loaded = loadFromRoots (loaderParams {
502
- tags : imports .Tags (),
503
- listRoots : func () []string { return nil },
504
- allClosesOverTests : index .allPatternClosesOverTests (), // but doesn't matter because the root list is empty.
505
- })
506
- return buildList
507
- }
508
-
509
452
// LoadALL returns the set of all packages in the current module
510
453
// and their dependencies in any other modules, without filtering
511
454
// due to build tags, except "+build ignore".
@@ -571,52 +514,6 @@ func TargetPackages(ctx context.Context, pattern string) *search.Match {
571
514
return m
572
515
}
573
516
574
- // BuildList returns the module build list,
575
- // typically constructed by a previous call to
576
- // LoadBuildList or ImportPaths.
577
- // The caller must not modify the returned list.
578
- func BuildList () []module.Version {
579
- return buildList
580
- }
581
-
582
- // SetBuildList sets the module build list.
583
- // The caller is responsible for ensuring that the list is valid.
584
- // SetBuildList does not retain a reference to the original list.
585
- func SetBuildList (list []module.Version ) {
586
- buildList = append ([]module.Version {}, list ... )
587
- }
588
-
589
- // TidyBuildList trims the build list to the minimal requirements needed to
590
- // retain the same versions of all packages from the preceding Load* or
591
- // ImportPaths* call.
592
- func TidyBuildList () {
593
- used := map [module.Version ]bool {Target : true }
594
- for _ , pkg := range loaded .pkgs {
595
- used [pkg .mod ] = true
596
- }
597
-
598
- keep := []module.Version {Target }
599
- var direct []string
600
- for _ , m := range buildList [1 :] {
601
- if used [m ] {
602
- keep = append (keep , m )
603
- if loaded .direct [m .Path ] {
604
- direct = append (direct , m .Path )
605
- }
606
- } else if cfg .BuildV {
607
- if _ , ok := index .require [m ]; ok {
608
- fmt .Fprintf (os .Stderr , "unused %s\n " , m .Path )
609
- }
610
- }
611
- }
612
-
613
- min , err := mvs .Req (Target , direct , & mvsReqs {buildList : keep })
614
- if err != nil {
615
- base .Fatalf ("go: %v" , err )
616
- }
617
- buildList = append ([]module.Version {Target }, min ... )
618
- }
619
-
620
517
// ImportMap returns the actual package import path
621
518
// for an import path found in source code.
622
519
// If the given import path does not appear in the source code
0 commit comments