@@ -588,6 +588,20 @@ func runGet(ctx context.Context, cmd *base.Command, args []string) {
588
588
modload .LoadPackages (ctx , loadOpts , pkgPatterns ... )
589
589
}
590
590
591
+ // If -d was specified, we're done after the module work.
592
+ // We've already downloaded modules by loading packages above.
593
+ // Otherwise, we need to build and install the packages matched by
594
+ // command line arguments. This may be a different set of packages,
595
+ // since we only build packages for the target platform.
596
+ // Note that 'go get -u' without arguments is equivalent to
597
+ // 'go get -u .', so we'll typically build the package in the current
598
+ // directory.
599
+ if ! * getD && len (pkgPatterns ) > 0 {
600
+ work .BuildInit ()
601
+ pkgs := load .PackagesForBuild (ctx , pkgPatterns )
602
+ work .InstallPackages (ctx , pkgPatterns , pkgs )
603
+ }
604
+
591
605
// Everything succeeded. Update go.mod.
592
606
modload .AllowWriteGoMod ()
593
607
modload .WriteGoMod ()
@@ -600,21 +614,6 @@ func runGet(ctx context.Context, cmd *base.Command, args []string) {
600
614
// contains information about direct dependencies that WriteGoMod uses.
601
615
// Refactor to avoid these kinds of global side effects.
602
616
reportRetractions (ctx )
603
-
604
- // If -d was specified, we're done after the module work.
605
- // We've already downloaded modules by loading packages above.
606
- // Otherwise, we need to build and install the packages matched by
607
- // command line arguments. This may be a different set of packages,
608
- // since we only build packages for the target platform.
609
- // Note that 'go get -u' without arguments is equivalent to
610
- // 'go get -u .', so we'll typically build the package in the current
611
- // directory.
612
- if * getD || len (pkgPatterns ) == 0 {
613
- return
614
- }
615
- work .BuildInit ()
616
- pkgs := load .PackagesForBuild (ctx , pkgPatterns )
617
- work .InstallPackages (ctx , pkgPatterns , pkgs )
618
617
}
619
618
620
619
// parseArgs parses command-line arguments and reports errors.
0 commit comments