Skip to content

Add a runtime method to find out if race detector is enabled #48944

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
anatol opened this issue Oct 13, 2021 · 1 comment
Closed

Add a runtime method to find out if race detector is enabled #48944

anatol opened this issue Oct 13, 2021 · 1 comment

Comments

@anatol
Copy link

anatol commented Oct 13, 2021

My version go version go1.17.1 linux/amd64

I have a code that needs to know whether the application runs with the race detector or not. In a way that is similar to testing.Verbose() tells whether -verbose flag is used.

I looked at public runtime library and did not find any method that allows to get information about the race detector. There is a SO question about it https://stackoverflow.com/questions/44944959/how-can-i-check-if-the-race-detector-is-enabled-at-runtime and it proposes a solution that uses buildtags. And there are many uses who follows this approach.

But it would be better if golang runtime library provided a cleaner way to find out if the race detector is enabled.

@ALTree
Copy link
Member

ALTree commented Oct 13, 2021

Tracked in #36477, closing here in favour of the older thread. Feel free to subscribe/comment in that one.

@ALTree ALTree closed this as completed Oct 13, 2021
@golang golang locked and limited conversation to collaborators Oct 13, 2022
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

3 participants