"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/cmd/go/internal/modcmd/download.go" between
go1.16.4.src.tar.gz and go1.16.5.src.tar.gz

About: Google’s Go is a compiled, garbage-collected, concurrent programming language. Latest stable release (1.16).

download.go  (go1.16.4.src):download.go  (go1.16.5.src)
skipping to change at line 89 skipping to change at line 89
Sum string `json:",omitempty"` Sum string `json:",omitempty"`
GoModSum string `json:",omitempty"` GoModSum string `json:",omitempty"`
} }
func runDownload(ctx context.Context, cmd *base.Command, args []string) { func runDownload(ctx context.Context, cmd *base.Command, args []string) {
// Check whether modules are enabled and whether we're in a module. // Check whether modules are enabled and whether we're in a module.
modload.ForceUseModules = true modload.ForceUseModules = true
if !modload.HasModRoot() && len(args) == 0 { if !modload.HasModRoot() && len(args) == 0 {
base.Fatalf("go mod download: no modules specified (see 'go help mod download')") base.Fatalf("go mod download: no modules specified (see 'go help mod download')")
} }
if len(args) == 0 { haveExplicitArgs := len(args) > 0
if !haveExplicitArgs {
args = []string{"all"} args = []string{"all"}
} else if modload.HasModRoot() { }
if modload.HasModRoot() {
modload.LoadModFile(ctx) // to fill Target modload.LoadModFile(ctx) // to fill Target
targetAtUpgrade := modload.Target.Path + "@upgrade" targetAtUpgrade := modload.Target.Path + "@upgrade"
targetAtPatch := modload.Target.Path + "@patch" targetAtPatch := modload.Target.Path + "@patch"
for _, arg := range args { for _, arg := range args {
switch arg { switch arg {
case modload.Target.Path, targetAtUpgrade, targetAtPatch: case modload.Target.Path, targetAtUpgrade, targetAtPatch:
os.Stderr.WriteString("go mod download: skipping argument " + arg + " that resolves to the main module\n") os.Stderr.WriteString("go mod download: skipping argument " + arg + " that resolves to the main module\n")
} }
} }
} }
skipping to change at line 140 skipping to change at line 142
return return
} }
} }
var mods []*moduleJSON var mods []*moduleJSON
listU := false listU := false
listVersions := false listVersions := false
listRetractions := false listRetractions := false
type token struct{} type token struct{}
sem := make(chan token, runtime.GOMAXPROCS(0)) sem := make(chan token, runtime.GOMAXPROCS(0))
for _, info := range modload.ListModules(ctx, args, listU, listVersions, infos := modload.ListModules(ctx, args, listU, listVersions, listRetracti
listRetractions) { ons)
if !haveExplicitArgs {
// 'go mod download' is sometimes run without arguments to pre-po
pulate
// the module cache. It may fetch modules that aren't needed to b
uild
// packages in the main mdoule. This is usually not intended, so
don't save
// sums for downloaded modules (golang.org/issue/45332).
// TODO(golang.org/issue/45551): For now, save sums needed to loa
d the
// build list (same as 1.15 behavior). In the future, report an e
rror if
// go.mod or go.sum need to be updated after loading the build li
st.
modload.WriteGoMod()
modload.DisallowWriteGoMod()
}
for _, info := range infos {
if info.Replace != nil { if info.Replace != nil {
info = info.Replace info = info.Replace
} }
if info.Version == "" && info.Error == nil { if info.Version == "" && info.Error == nil {
// main module or module replaced with file path. // main module or module replaced with file path.
// Nothing to download. // Nothing to download.
continue continue
} }
m := &moduleJSON{ m := &moduleJSON{
Path: info.Path, Path: info.Path,
skipping to change at line 190 skipping to change at line 205
} }
} else { } else {
for _, m := range mods { for _, m := range mods {
if m.Error != "" { if m.Error != "" {
base.Errorf("go mod download: %v", m.Error) base.Errorf("go mod download: %v", m.Error)
} }
} }
base.ExitIfErrors() base.ExitIfErrors()
} }
// Update go.mod and especially go.sum if needed. // If there were explicit arguments, update go.mod and especially go.sum.
modload.WriteGoMod() // 'go mod download mod@version' is a useful way to add a sum without usi
ng
// 'go get mod@version', which may have other side effects. We print this
in
// some error message hints.
//
// Don't save sums for 'go mod download' without arguments; see comment a
bove.
if haveExplicitArgs {
modload.WriteGoMod()
}
} }
 End of changes. 4 change blocks. 
6 lines changed or deleted 37 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)