Skip to content

proposal: internal/coverage: Expose emitCounterData to create code coverage while the binary is running #71983

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

Closed
KevinFairise2 opened this issue Feb 26, 2025 · 1 comment
Labels
Milestone

Comments

@KevinFairise2
Copy link

Proposal Details

When building a binary with go build -cover. The emitCounterData is registered on exit which create the coverage file when the program exits successfully.

I think it would be useful to be allowed to call that function (or another one that would register the coverage) when the program is running.
It makes it possible to get the coverage at different time during the code execution. It can also be a way to get the coverage even if the binary does not exit succesfully.
This would also be very convenient for programs that are not made to be stopped, that way you can get the coverage without needing to explicitly stopping the execution of the code.

I think that would something convenient, but let me know what you think about that and if there are any big blocker that I did not anticipate

@gopherbot gopherbot added this to the Proposal milestone Feb 26, 2025
@seankhliao
Copy link
Member

see https://pkg.go.dev/runtime/coverage

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Feb 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants