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' of a replaced module downloads the go.mod for its replacement #29181

Open
bcmills opened this issue Dec 12, 2018 · 2 comments

Comments

@bcmills
Copy link
Member

@bcmills bcmills commented Dec 12, 2018

go mod download of a specific version of a module should download only that module.

Today, if that version happens to have a replacement, go mod download also downloads the go.mod file (but not the .zip file) for its replacement.

$ go mod init golang.org/issue/scratch
go: creating new go.mod: module golang.org/issue/scratch

$ go mod edit -require golang.org/x/text@v0.2.0
$ go mod edit -replace golang.org/x/text@v0.2.0=golang.org/x/text@v0.3.0
$ go mod download -json golang.org/x/text@v0.2.0
go: finding golang.org/x/text v0.3.0
go: finding golang.org/x/text v0.2.0
{
        "Path": "golang.org/x/text",
        "Version": "v0.2.0",
        "Info": "/tmp/tmp.3uwW75Tyk7/_gopath/pkg/mod/cache/download/golang.org/x/text/@v/v0.2.0.info",
        "GoMod": "/tmp/tmp.3uwW75Tyk7/_gopath/pkg/mod/cache/download/golang.org/x/text/@v/v0.2.0.mod",
        "Zip": "/tmp/tmp.3uwW75Tyk7/_gopath/pkg/mod/cache/download/golang.org/x/text/@v/v0.2.0.zip",
        "Dir": "/tmp/tmp.3uwW75Tyk7/_gopath/pkg/mod/golang.org/x/text@v0.2.0",
        "Sum": "h1:WtDSLEtcB5GqbjSlyn8XcYtxjw+SgFMc2RILOvq7CuE=",
        "GoModSum": "h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ="
}

$ find $GOPATH -name '*.mod'
/tmp/tmp.3uwW75Tyk7/_gopath/pkg/mod/cache/download/golang.org/x/text/@v/v0.2.0.mod
/tmp/tmp.3uwW75Tyk7/_gopath/pkg/mod/cache/download/golang.org/x/text/@v/v0.3.0.mod

$ find $GOPATH -name '*.zip'
/tmp/tmp.3uwW75Tyk7/_gopath/pkg/mod/cache/download/golang.org/x/text/@v/v0.2.0.zip
@bcmills bcmills added this to the Go1.13 milestone Dec 12, 2018
@bcmills

This comment has been minimized.

Copy link
Member Author

@bcmills bcmills commented Dec 12, 2018

(Found while investigating #27868.)

@oiooj

This comment has been minimized.

Copy link
Contributor

@oiooj oiooj commented Dec 16, 2018

I fixed this problem in my local repo, but from the test script:

go mod download will not follow replacements for explicit module queries.

Maybe we need to think about it again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.