for _, arg := range args {
switch arg {
case modload.Target.Path, targetAtLatest, 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")
}
}
}
if info.Replace != nil {
info = info.Replace
}
- if (module.Version{Path: info.Path, Version: info.Version} == modload.Target) {
- // skipping main module.
- // go mod download without dependencies is silent.
+ if info.Version == "" && info.Error == nil {
+ // main module or module replaced with file path.
+ // Nothing to download.
continue
}
m := &moduleJSON{
--- /dev/null
+# This test checks that 'go mod download' produces no output for
+# the main module (when specified implicitly) and for a module replaced
+# with a file path.
+# Verifies golang.org/issue/35505.
+go mod download -json all
+cmp stdout no-output
+
+-- go.mod --
+module example.com/a
+
+require example.com/b v1.0.0
+
+replace example.com/b => ./local/b
+-- local/b/go.mod --
+module example.com/b
+-- no-output --