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: preserve sums for contents of modules required by go.mod #41103

Closed
jayconrod opened this issue Aug 28, 2020 · 4 comments
Closed

cmd/go: preserve sums for contents of modules required by go.mod #41103

jayconrod opened this issue Aug 28, 2020 · 4 comments
Labels
FrozenDueToAge modules NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Milestone

Comments

@jayconrod
Copy link
Contributor

What version of Go are you using (go version)?

3b6c812f3defa90bfd7dbddf24bc6135adc5a7eb

Does this issue reproduce with the latest release?

No, this is a regression in 1.16 development, probably caused by CL 237017.

What did you do?

go get any module that has no package in its root directory.

go mod init m
go get golang.org/x/tools
grep 'golang.org/x/tools [^/]* ' go.sum

go get will add a sum for the module's go.mod file to go.sum, but it won't add a sum for the module's content to go.sum.

What did you expect to see?

go get should add sums for the module's go.mod file and its content to go.sum.

What did you see instead?

go get only adds a sum for the module's go.mod file.

@jayconrod jayconrod added NeedsFix The path to resolution is known, but the work has not been done. modules labels Aug 28, 2020
@jayconrod jayconrod added this to the Go1.16 milestone Aug 28, 2020
@jayconrod jayconrod self-assigned this Aug 28, 2020
@ekalinin
Copy link
Contributor

Looks like it fixed:

➜ git log -n1 | head -n5
commit ba0fab3cb731fe9a383bd61c3480cccfe32bb1f4
Author: Ian Lance Taylor <iant@golang.org>
Date:   Sat Aug 29 14:11:18 2020 -0700

    debug/elf: run relocation tests in parallel

➜ ./make.bash

➜ go version               
go version devel +ba0fab3cb7 Sun Aug 30 03:53:59 2020 +0000 linux/amd64

➜ cat cmd/go/testdata/script/mod_get_gosum_fill.txt      
go mod init m
go get rsc.io/sampler
grep 'rsc.io/sampler [^/]* ' go.mod
grep 'rsc.io/sampler [^/]* ' go.sum
cmp go.sum x.sum
-- x.sum --
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c h1:pvCbr/wm8HzDD3fVywevekufpn6tCGPY3spdHeZJEsw=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
rsc.io/sampler v1.99.99 h1:iMG9lbEG/8MdeR4lgL+Q8IcwbLNw7ijW7fTiK8Miqts=
rsc.io/sampler v1.99.99/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=

➜ go test cmd/go -run=TestScript/mod_get_gosum_fill   
ok  	cmd/go	(cached)

@jayconrod
Copy link
Contributor Author

@ekalin rsc.io/sampler has a package in its root directory, so it's not affected by this issue.

This is specifically about modules without packages in their root directories, like golang.org/x/tools.

@gopherbot
Copy link

Change https://golang.org/cl/251880 mentions this issue: cmd/go: make 'go get' preserve sums for content of new requirements

@gopherbot
Copy link

Change https://golang.org/cl/282692 mentions this issue: cmd/go: preserve sums for indirect deps fetched by 'go mod download'

gopherbot pushed a commit that referenced this issue Jan 8, 2021
Previously, commands that wrote go.sum (except 'go mod tidy') would
retain sums for zip files of directly required modules. Sums of
indirect dependencies wouldn't be retained unless they were used to
load packages.

With this change, sums for indirect dependencies will be retained if
they're available. This allows users to add missing sums with
'go mod download example.com/mod', which previously only worked for
directly required modules.

Note that 'go mod download' without arguments now adds sums for every
module in the build list. That matches 1.15 behavior.

For #41103

Change-Id: I4cce2bf1c73578dae836bdb5adb32da071554f1a
Reviewed-on: https://go-review.googlesource.com/c/go/+/282692
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
@golang golang locked and limited conversation to collaborators Jan 8, 2022
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. release-blocker
Projects
None yet
Development

No branches or pull requests

4 participants