Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: go mod download doesn't do anything if you give it a module without a version #27783

Closed
natefinch opened this issue Sep 20, 2018 · 7 comments
Labels
FrozenDueToAge modules NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@natefinch
Copy link
Contributor

natefinch commented Sep 20, 2018

So, I didn't realize that go mod download required an @version at the end... I presumed it would default to @latest just like it would if you import a library without specifying a version in your go.mod. However, instead, go mod download just silently fails.

What did you do?

(in a directory outside GOPATH with a go.mod that did not include github.com/lib/pq)
go mod download github.com/lib/pq

What did you expect to see?

some version of lib/pq downloaded, or an error

What did you see instead?

nothing happened and no error

System details

go version go1.11 darwin/amd64
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/finchnat/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/finchnat"
GOPROXY=""
GORACE=""
GOROOT="/Users/finchnat/sdk/go1.11"
GOTMPDIR=""
GOTOOLDIR="/Users/finchnat/sdk/go1.11/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/finchnat/dev/test/go.mod"
GOROOT/bin/go version: go version go1.11 darwin/amd64
GOROOT/bin/go tool compile -V: compile version go1.11
uname -v: Darwin Kernel Version 17.7.0: Thu Jun 21 22:53:14 PDT 2018; root:xnu-4570.71.2~1/RELEASE_X86_64
ProductName:	Mac OS X
ProductVersion:	10.13.6
BuildVersion:	17G65
lldb --version: lldb-902.0.79.7
  Swift-4.1
@natefinch
Copy link
Contributor Author

Notably, I'd prefer "no version" to default to @latest ... but it at the very least should tell me I gave it something invalid.

@bcmills bcmills added the NeedsFix The path to resolution is known, but the work has not been done. label Sep 22, 2018
@bcmills bcmills added this to the Go1.12 milestone Sep 22, 2018
@hyangah
Copy link
Contributor

hyangah commented Oct 9, 2018

'go mod download' should report errors and failure if any.

$ go mod download somethingveryfake.com/fake
$

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/144106 mentions this issue: cmd/go/internal/modcmd: warn when no version supplied to go mod download

@bcmills bcmills modified the milestones: Go1.12, Go1.13 Nov 14, 2018
@bcmills bcmills changed the title cmd/go: go mod download doesn't do anything if you give it a package without a version cmd/go: go mod download doesn't do anything if you give it a module without a version Nov 15, 2018
@gopherbot
Copy link
Contributor

Change https://golang.org/cl/151559 mentions this issue: cmd/go/internal/modcmd: check for errors in Download

gopherbot pushed a commit that referenced this issue Nov 29, 2018
Also test that Download restores deleted files.

Updates #27783

Change-Id: If50074dbcffd74ff08fbaa9ad8c314cfdce0b02d
Reviewed-on: https://go-review.googlesource.com/c/151559
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
@gopherbot
Copy link
Contributor

Change https://golang.org/cl/174697 mentions this issue: cmd/go: fix error message for go mod in GOPATH mode

@iwdgo
Copy link
Contributor

iwdgo commented May 4, 2019

Issue is related to #31237, an error message displays with the submitted fix which seems to solve the issue:

$GOPATH\src\mymod>set GO111MODULE=on

$GOPATH\src\mymod>goissue mod download rsc.io/doesnotexist
go: cannot find main module; see 'go help modules'

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/179998 mentions this issue: cmd/go: fix error messages for go mod download in GOPATH mode

@golang golang locked and limited conversation to collaborators Jun 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge modules NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

5 participants