}
if len(args) == 0 {
args = []string{"all"}
+ } else if modload.HasModRoot() {
+ modload.InitMod() // to fill Target
+ targetAtLatest := modload.Target.Path + "@latest"
+ targetAtUpgrade := modload.Target.Path + "@upgrade"
+ targetAtPatch := modload.Target.Path + "@patch"
+ 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")
+ }
+ }
}
var mods []*moduleJSON
if info.Replace != nil {
info = info.Replace
}
- if info.Version == "" && info.Error == nil {
- // main module
+ if (module.Version{Path: info.Path, Version: info.Version} == modload.Target) {
+ // skipping main module.
+ // go mod download without dependencies is silent.
continue
}
m := &moduleJSON{
! go mod download -json bad/path
stdout '^\t"Error": "module bad/path: not a known dependency"'
+# download main module returns an error
+go mod download m
+stderr '^go mod download: skipping argument m that resolves to the main module\n'
+go mod download m@latest
+stderr '^go mod download: skipping argument m@latest that resolves to the main module\n'
+
# allow go mod download without go.mod
env GO111MODULE=auto
rm go.mod