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: allow go mod download without go.mod #29522

Open
rsc opened this Issue Jan 3, 2019 · 3 comments

Comments

Projects
None yet
4 participants
@rsc
Copy link
Contributor

rsc commented Jan 3, 2019

There's no need for go.mod to be present for go mod download to work.
Right now I get weird errors:

$ mkdir /tmp/zz
$ cd /tmp/zz
$ go mod download golang.org/x/exp@latest
golang.org/x/exp@latest: invalid version "latest"
$ go mod download -json golang.org/x/exp@latest
{
	"Path": "golang.org/x/exp",
	"Version": "latest",
	"Error": "invalid version \"latest\""
}
$ echo module m >go.mod
$ go mod download golang.org/x/exp@latest
go: finding golang.org/x/exp latest
$ go mod download -json golang.org/x/exp@latest
go: finding golang.org/x/exp latest
{
	"Path": "golang.org/x/exp",
	"Version": "v0.0.0-20181221233300-b68661188fbf",
	"Info": "/Users/rsc/pkg/mod/cache/download/golang.org/x/exp/@v/v0.0.0-20181221233300-b68661188fbf.info",
	"GoMod": "/Users/rsc/pkg/mod/cache/download/golang.org/x/exp/@v/v0.0.0-20181221233300-b68661188fbf.mod",
	"Zip": "/Users/rsc/pkg/mod/cache/download/golang.org/x/exp/@v/v0.0.0-20181221233300-b68661188fbf.zip",
	"Dir": "/Users/rsc/pkg/mod/golang.org/x/exp@v0.0.0-20181221233300-b68661188fbf",
	"Sum": "h1:rK+9ETFkUX8OofKNLhik8qEGY/3gnM5x4eVNWJf1z/8=",
	"GoModSum": "h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA="
}
$ 

This affects development of module proxies and notaries and should be fixed (assuming it is trivial) for Go 1.12.

/cc @bcmills

@rsc rsc added this to the Go1.12 milestone Jan 3, 2019

@rsc

This comment has been minimized.

Copy link
Contributor

rsc commented Jan 3, 2019

Setting GO111MODULE=on makes the problem go away so it's not required for Go 1.12 after all.

@rsc rsc modified the milestones: Go1.12, Go1.13 Jan 3, 2019

@dmitshur dmitshur added the modules label Jan 3, 2019

@gopherbot

This comment has been minimized.

Copy link

gopherbot commented Jan 15, 2019

Change https://golang.org/cl/157937 mentions this issue: cmd/go/internal/modcmd: allow mod download without go.mod

@oiooj

This comment has been minimized.

Copy link
Member

oiooj commented Jan 15, 2019

The CL 148517 is a big change.

Although I submit a test case, the test script engine can't reproduce this issue. Because the engine uses a proxy.

on my laptop:

$export GO111MODULE=auto

$go mod download rsc.io/quote@v1.2.1
rsc.io/quote@v1.2.1: codehost.WorkRoot not set

The test print before fix:

            [stderr]
            go: finding rsc.io/quote v1.5.1
            > exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.1.zip
            # allow go mod download without go.mod (0.105s)
            > env GO111MODULE=auto
            > rm go.mod
            > rm $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.2.1.zip
            > go mod download rsc.io/quote@v1.2.1
            [stderr]
            go: finding rsc.io/quote v1.2.1
            > exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.2.1.zip
            PASS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment