@@ -314,10 +314,6 @@ func LoadPackages(ctx context.Context, opts PackageOpts, patterns ...string) (ma
314
314
315
315
initialRS , _ := loadModFile (ctx ) // Ignore needCommit — we're going to commit at the end regardless.
316
316
317
- if opts .GoVersion == "" {
318
- opts .GoVersion = modFileGoVersion ()
319
- }
320
-
321
317
ld := loadFromRoots (ctx , loaderParams {
322
318
PackageOpts : opts ,
323
319
requirements : initialRS ,
@@ -380,7 +376,7 @@ func LoadPackages(ctx context.Context, opts PackageOpts, patterns ...string) (ma
380
376
381
377
// Success! Update go.mod and go.sum (if needed) and return the results.
382
378
loaded = ld
383
- commitRequirements (ctx , opts .GoVersion , loaded .requirements )
379
+ commitRequirements (ctx , loaded .GoVersion , loaded .requirements )
384
380
385
381
for _ , pkg := range ld .pkgs {
386
382
if ! pkg .isTest () {
@@ -605,10 +601,8 @@ func ImportFromFiles(ctx context.Context, gofiles []string) {
605
601
base .Fatalf ("go: %v" , err )
606
602
}
607
603
608
- goVersion := modFileGoVersion ()
609
604
loaded = loadFromRoots (ctx , loaderParams {
610
605
PackageOpts : PackageOpts {
611
- GoVersion : goVersion ,
612
606
Tags : tags ,
613
607
ResolveMissingImports : true ,
614
608
SilencePackageErrors : true ,
@@ -620,7 +614,7 @@ func ImportFromFiles(ctx context.Context, gofiles []string) {
620
614
return roots
621
615
},
622
616
})
623
- commitRequirements (ctx , goVersion , loaded .requirements )
617
+ commitRequirements (ctx , loaded . GoVersion , loaded .requirements )
624
618
}
625
619
626
620
// DirImportPath returns the effective import path for dir,
@@ -921,26 +915,25 @@ func loadFromRoots(ctx context.Context, params loaderParams) *loader {
921
915
work : par .NewQueue (runtime .GOMAXPROCS (0 )),
922
916
}
923
917
924
- if params .GoVersion != "" {
925
- goVersionV := "v" + params .GoVersion
926
- if semver .Compare (goVersionV , narrowAllVersionV ) < 0 && ! ld .UseVendorAll {
927
- // The module's go version explicitly predates the change in "all" for lazy
928
- // loading, so continue to use the older interpretation.
929
- // (If params.GoVersion is empty, we are probably not in any module at all
930
- // and should use the latest semantics.)
931
- ld .allClosesOverTests = true
932
- }
918
+ if ld .GoVersion == "" {
919
+ ld .GoVersion = modFileGoVersion ()
933
920
934
- if ld .Tidy && semver .Compare (goVersionV , "v" + LatestGoVersion ()) > 0 {
935
- ld .errorf ("go mod tidy: go.mod file indicates go %s, but maximum supported version is %s\n " , params .GoVersion , LatestGoVersion ())
921
+ if ld .Tidy && semver .Compare ("v" + ld . GoVersion , "v" + LatestGoVersion ()) > 0 {
922
+ ld .errorf ("go mod tidy: go.mod file indicates go %s, but maximum supported version is %s\n " , ld .GoVersion , LatestGoVersion ())
936
923
base .ExitIfErrors ()
937
924
}
925
+ }
938
926
939
- var err error
940
- ld .requirements , err = convertDepth (ctx , ld .requirements , modDepthFromGoVersion (params .GoVersion ))
941
- if err != nil {
942
- ld .errorf ("go: %v\n " , err )
943
- }
927
+ if semver .Compare ("v" + ld .GoVersion , narrowAllVersionV ) < 0 && ! ld .UseVendorAll {
928
+ // The module's go version explicitly predates the change in "all" for lazy
929
+ // loading, so continue to use the older interpretation.
930
+ ld .allClosesOverTests = true
931
+ }
932
+
933
+ var err error
934
+ ld .requirements , err = convertDepth (ctx , ld .requirements , modDepthFromGoVersion (ld .GoVersion ))
935
+ if err != nil {
936
+ ld .errorf ("go: %v\n " , err )
944
937
}
945
938
946
939
if ld .requirements .depth == eager {
0 commit comments