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
Labels
GoCommand cmd/go modules NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@bcmills
Copy link
Contributor

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 NeedsFix The path to resolution is known, but the work has not been done. GoCommand cmd/go modules labels Dec 12, 2018
@bcmills bcmills added this to the Go1.13 milestone Dec 12, 2018
@bcmills
Copy link
Contributor Author

bcmills commented Dec 12, 2018

(Found while investigating #27868.)

@oiooj
Copy link
Member

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
Labels
GoCommand cmd/go modules NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants