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/cover: Allow specifying uncovered lines #12504

Closed
brunokim opened this issue Sep 4, 2015 · 2 comments
Closed

cmd/cover: Allow specifying uncovered lines #12504

brunokim opened this issue Sep 4, 2015 · 2 comments

Comments

@brunokim
Copy link

brunokim commented Sep 4, 2015

In this reddit discussion, /u/jerf has a nice suggestion: label lines that should be impossible to reach to improve coverage. Something like follows:

res, err := prudentFunction("constant")
if err != nil {
  panic(fmt.Sprintf("The impossible has happened: %v", err)) // gocover: Ignore
}

The coverage tool could then instrument the line and ignore it if there are 0 passes, and issue an error if there were more than zero.

@ianlancetaylor ianlancetaylor added this to the Unplanned milestone Sep 4, 2015
@ianlancetaylor
Copy link
Contributor

CC @robpike

@robpike
Copy link
Contributor

robpike commented Sep 5, 2015

No, thanks. I dislike tools forcing people to annotate their code to silence them. That is, I dislike these annotations - they're not about the code, only about the tools that analyze the code.

@robpike robpike closed this as completed Sep 5, 2015
@golang golang locked and limited conversation to collaborators Sep 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants