@@ -426,7 +426,7 @@ func runGet(ctx context.Context, cmd *base.Command, args []string) {
426
426
427
427
if gowork := modload .FindGoWork (base .Cwd ()); gowork != "" {
428
428
wf , err := modload .ReadWorkFile (gowork )
429
- if err == nil && modload .UpdateWorkGoVersion (wf , modload .MainModules .GoVersion ()) {
429
+ if err == nil && modload .UpdateWorkGoVersion (wf , modload .LoaderState . MainModules .GoVersion ()) {
430
430
modload .WriteWorkFile (gowork , wf )
431
431
}
432
432
}
@@ -722,7 +722,7 @@ func (r *resolver) queryNone(ctx context.Context, q *query) {
722
722
if ! q .isWildcard () {
723
723
q .pathOnce (q .pattern , func () pathSet {
724
724
hasModRoot := modload .HasModRoot ()
725
- if hasModRoot && modload .MainModules .Contains (q .pattern ) {
725
+ if hasModRoot && modload .LoaderState . MainModules .Contains (q .pattern ) {
726
726
v := module.Version {Path : q .pattern }
727
727
// The user has explicitly requested to downgrade their own module to
728
728
// version "none". This is not an entirely unreasonable request: it
@@ -746,7 +746,7 @@ func (r *resolver) queryNone(ctx context.Context, q *query) {
746
746
continue
747
747
}
748
748
q .pathOnce (curM .Path , func () pathSet {
749
- if modload .HasModRoot () && curM .Version == "" && modload .MainModules .Contains (curM .Path ) {
749
+ if modload .HasModRoot () && curM .Version == "" && modload .LoaderState . MainModules .Contains (curM .Path ) {
750
750
return errSet (& modload.QueryMatchesMainModulesError {MainModules : []module.Version {curM }, Pattern : q .pattern , Query : q .version })
751
751
}
752
752
return pathSet {mod : module.Version {Path : curM .Path , Version : "none" }}
@@ -766,13 +766,13 @@ func (r *resolver) performLocalQueries(ctx context.Context) {
766
766
767
767
// Absolute paths like C:\foo and relative paths like ../foo... are
768
768
// restricted to matching packages in the main module.
769
- pkgPattern , mainModule := modload .MainModules .DirImportPath (ctx , q .pattern )
769
+ pkgPattern , mainModule := modload .LoaderState . MainModules .DirImportPath (ctx , q .pattern )
770
770
if pkgPattern == "." {
771
771
modload .MustHaveModRoot ()
772
- versions := modload .MainModules .Versions ()
772
+ versions := modload .LoaderState . MainModules .Versions ()
773
773
modRoots := make ([]string , 0 , len (versions ))
774
774
for _ , m := range versions {
775
- modRoots = append (modRoots , modload .MainModules .ModRoot (m ))
775
+ modRoots = append (modRoots , modload .LoaderState . MainModules .ModRoot (m ))
776
776
}
777
777
var plural string
778
778
if len (modRoots ) != 1 {
@@ -792,7 +792,7 @@ func (r *resolver) performLocalQueries(ctx context.Context) {
792
792
}
793
793
if ! q .isWildcard () {
794
794
modload .MustHaveModRoot ()
795
- return errSet (fmt .Errorf ("%s%s is not a package in module rooted at %s" , q .pattern , absDetail , modload .MainModules .ModRoot (mainModule )))
795
+ return errSet (fmt .Errorf ("%s%s is not a package in module rooted at %s" , q .pattern , absDetail , modload .LoaderState . MainModules .ModRoot (mainModule )))
796
796
}
797
797
search .WarnUnmatched ([]* search.Match {match })
798
798
return pathSet {}
@@ -848,7 +848,7 @@ func (r *resolver) queryWildcard(ctx context.Context, q *query) {
848
848
return pathSet {}
849
849
}
850
850
851
- if modload .MainModules .Contains (curM .Path ) && ! versionOkForMainModule (q .version ) {
851
+ if modload .LoaderState . MainModules .Contains (curM .Path ) && ! versionOkForMainModule (q .version ) {
852
852
if q .matchesPath (curM .Path ) {
853
853
return errSet (& modload.QueryMatchesMainModulesError {
854
854
MainModules : []module.Version {curM },
@@ -1065,7 +1065,7 @@ func (r *resolver) queryPath(ctx context.Context, q *query) {
1065
1065
// pattern is "tool".
1066
1066
func (r * resolver ) performToolQueries (ctx context.Context ) {
1067
1067
for _ , q := range r .toolQueries {
1068
- for tool := range modload .MainModules .Tools () {
1068
+ for tool := range modload .LoaderState . MainModules .Tools () {
1069
1069
q .pathOnce (tool , func () pathSet {
1070
1070
pkgMods , err := r .queryPackages (ctx , tool , q .version , r .initialSelected )
1071
1071
return pathSet {pkgMods : pkgMods , err : err }
@@ -1082,10 +1082,10 @@ func (r *resolver) performWorkQueries(ctx context.Context) {
1082
1082
// TODO(matloob): Maybe export MainModules.mustGetSingleMainModule and call that.
1083
1083
// There are a few other places outside the modload package where we expect
1084
1084
// a single main module.
1085
- if len (modload .MainModules .Versions ()) != 1 {
1085
+ if len (modload .LoaderState . MainModules .Versions ()) != 1 {
1086
1086
panic ("internal error: number of main modules is not exactly one in resolution phase of go get" )
1087
1087
}
1088
- mainModule := modload .MainModules .Versions ()[0 ]
1088
+ mainModule := modload .LoaderState . MainModules .Versions ()[0 ]
1089
1089
1090
1090
// We know what the result is going to be, assuming the main module is not
1091
1091
// empty, (it's the main module itself) but first check to see that there
@@ -1496,7 +1496,7 @@ func (r *resolver) disambiguate(cs pathSet) (filtered pathSet, isPackage bool, m
1496
1496
continue
1497
1497
}
1498
1498
1499
- if modload .MainModules .Contains (m .Path ) {
1499
+ if modload .LoaderState . MainModules .Contains (m .Path ) {
1500
1500
if m .Version == "" {
1501
1501
return pathSet {}, true , m , true
1502
1502
}
@@ -1612,7 +1612,7 @@ func (r *resolver) checkPackageProblems(ctx context.Context, pkgPatterns []strin
1612
1612
// info, but switch back to single module mode when fetching sums so that we update
1613
1613
// the single module's go.sum file.
1614
1614
var exitWorkspace func ()
1615
- if r .workspace != nil && r .workspace .hasModule (modload .MainModules .Versions ()[0 ].Path ) {
1615
+ if r .workspace != nil && r .workspace .hasModule (modload .LoaderState . MainModules .Versions ()[0 ].Path ) {
1616
1616
var err error
1617
1617
exitWorkspace , err = modload .EnterWorkspace (ctx )
1618
1618
if err != nil {
@@ -1951,7 +1951,7 @@ func (r *resolver) resolve(q *query, m module.Version) {
1951
1951
panic ("internal error: resolving a module.Version with an empty path" )
1952
1952
}
1953
1953
1954
- if modload .MainModules .Contains (m .Path ) && m .Version != "" {
1954
+ if modload .LoaderState . MainModules .Contains (m .Path ) && m .Version != "" {
1955
1955
reportError (q , & modload.QueryMatchesMainModulesError {
1956
1956
MainModules : []module.Version {{Path : m .Path }},
1957
1957
Pattern : q .pattern ,
@@ -1983,7 +1983,7 @@ func (r *resolver) updateBuildList(ctx context.Context, additions []module.Versi
1983
1983
1984
1984
resolved := make ([]module.Version , 0 , len (r .resolvedVersion ))
1985
1985
for mPath , rv := range r .resolvedVersion {
1986
- if ! modload .MainModules .Contains (mPath ) {
1986
+ if ! modload .LoaderState . MainModules .Contains (mPath ) {
1987
1987
resolved = append (resolved , module.Version {Path : mPath , Version : rv .version })
1988
1988
}
1989
1989
}
0 commit comments