Skip to content

cmd/go: no way to check staleness of targets built with coverage  #57785

@thanm

Description

@thanm

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

$ go version
go version devel go1.20-6d34903a85 Fri Jan 13 10:31:21 2023 -0500 linux/amd64

Does this issue reproduce with the latest release?

No.

What operating system and processor architecture are you using (go env)?

Linux/amd64

What did you do?

When I install Go commands (such as cmd/link, cmd/compile) as part of coverage testing scripts (intended to collect coverage for Go itself), I find that I can't use "go list" in the normal way to test for staleness. Example:

$ // Here is a regular install; no problems here.
$ go install cmd/nm
$ go list "-f={{if .Stale}}\tSTALE {{.ImportPath}}: {{.StaleReason}}{{end}}"  cmd/nm
$
$ // Now I install an instrumented "nm"
$ go install -cover cmd/nm
$ go list "-f={{if .Stale}}\tSTALE {{.ImportPath}}: {{.StaleReason}}{{end}}"  cmd/nm
\tSTALE cmd/nm: stale dependency: internal/goarch
$ go list "-f={{if .Stale}}\tSTALE {{.ImportPath}}: {{.StaleReason}}{{end}}" -cover cmd/nm
flag provided but not defined: -cover
usage: go list [-f format] [-json] [-m] [list flags] [build flags] [packages]
Run 'go help list' for details.
$

The problem here is that the "go list" command accepts most build flags (e.g. "-x", "-tags", etc) but does not accept "-cover" and related flags.

This is something of a boutique use case, but I think it is still worth fixing.

Metadata

Metadata

Assignees

Labels

FrozenDueToAgeGoCommandcmd/goNeedsFixThe path to resolution is known, but the work has not been done.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions