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: do not report cached libraries as stale in module mode #46911

Open
bcmills opened this issue Jun 24, 2021 · 0 comments
Open

cmd/go: do not report cached libraries as stale in module mode #46911

bcmills opened this issue Jun 24, 2021 · 0 comments
Assignees
Milestone

Comments

@bcmills
Copy link
Member

@bcmills bcmills commented Jun 24, 2021

In module mode, non-main packages have no install path: built packages are stored only in the build cache. In module mode, go install for a non-main package only ensures that the build cache is up to date; it does not install the library elsewhere.

According to https://tip.golang.org/cmd/go/#hdr-List_packages_or_modules, the Stale field means:

would go install do anything for this package?

According to that interpretation, we should not report a library as Stale in module mode if it is already up to date in the build cache. Today, we always report libraries as stale:

$ go version
go version devel go1.17-a9bb38222 Thu Jun 24 03:45:33 2021 +0000 linux/amd64

$ go mod init example.com/m
go: creating new go.mod: module example.com/m

$ go get -d golang.org/x/tools/imports
go: downloading golang.org/x/tools v0.1.4
go: downloading golang.org/x/mod v0.4.2
go: downloading golang.org/x/sys v0.0.0-20210510120138-977fb7262007
go: downloading golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
go get: added golang.org/x/mod v0.4.2
go get: added golang.org/x/sys v0.0.0-20210510120138-977fb7262007
go get: added golang.org/x/tools v0.1.4
go get: added golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1

$ go list -f '{{if .Stale}}{{.StaleReason}}{{end}}' golang.org/x/tools/imports
stale dependency: golang.org/x/tools/internal/event/label

$ go install golang.org/x/tools/imports

$ go list -f '{{if .Stale}}{{.StaleReason}}{{end}}' golang.org/x/tools/imports
not installed but available in build cache

$ go install golang.org/x/tools/imports

$ go list -f '{{if .Stale}}{{.StaleReason}}{{end}}' golang.org/x/tools/imports
not installed but available in build cache

This came to my attention via https://stackoverflow.com/q/64462190.

CC @jayconrod @matloob

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant