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: cover tool help command syntax does not work on Windows #51126

Closed
spekary opened this issue Feb 10, 2022 · 4 comments
Closed

cmd/go: cover tool help command syntax does not work on Windows #51126

spekary opened this issue Feb 10, 2022 · 4 comments
Labels
Documentation FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@spekary
Copy link

spekary commented Feb 10, 2022

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

1.17.5

Does this issue reproduce with the latest release?

Yes

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

Windows

What did you do?

Running 'go tool cover -help' issues a help message that includes this command suggestion:

go tool cover -func=c.out

This works on the Mac and Linux, but not on Windows. On Windows it produces the following error message:

too many arguments For usage information, run "go tool cover -help"

The correct way to call this is:

go tool cover -func c.out

This works on all platforms.

Note that this bad usage pattern is sprinkled throughout the go ecosystem. For example, this web page: https://pkg.go.dev/cmd/cover, has this line:

Cover is a program for analyzing the coverage profiles generated by 'go test -coverprofile=cover.out'.

However, running that line in a windows cmd terminal produces:
no required module provides package .out; to add it: go get .out

Or here: https://pkg.go.dev/cmd/go#hdr-Build_constraints, it uses examples of -buildmode=mode, even though the documentation earlier specs it as -buildmode mode.

This clearly is a longstanding problem that should be easy to clean up.

@mdlayher mdlayher changed the title The Go command help gives command syntax that does not work on Windows cmd/go: cover tool help command syntax does not work on Windows Feb 10, 2022
@ALTree ALTree added Documentation NeedsFix The path to resolution is known, but the work has not been done. labels Feb 10, 2022
@ALTree ALTree added this to the Unplanned milestone Feb 10, 2022
@saurabh-sm
Copy link

saurabh-sm commented May 4, 2022

Seeing this error in GitHub action CI when running go tool cover -html=profile.out -o testcoverage.html.

The below commands precede the above and work fine:

go test -v ./... -coverprofile profile.out
go tool cover -func profile.out

@ianlancetaylor
Copy link
Contributor

I just tested and go tool cover -func=c.out works fine for me on Windows.

I don't understand why it wouldn't work, as the flag parsing is done by Go code and that Go code looks for =.

Can somebody who is having this problem debug it? Thanks.

@ianlancetaylor ianlancetaylor added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Jul 1, 2022
@seankhliao
Copy link
Member

This would be PowerShell/PowerShell#6291

@seankhliao
Copy link
Member

Closing as a PowerShell bug

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Jul 1, 2022
adam7 added a commit to admcpr/hub-bub that referenced this issue Mar 16, 2023
@golang golang locked and limited conversation to collaborators Jul 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

6 participants