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

proposal: runtime/debug: add const Race #36477

Open
ainar-g opened this issue Jan 9, 2020 · 4 comments
Open

proposal: runtime/debug: add const Race #36477

ainar-g opened this issue Jan 9, 2020 · 4 comments
Labels
Milestone

Comments

@ainar-g
Copy link
Contributor

@ainar-g ainar-g commented Jan 9, 2020

I've seen a lot of code like this:

// +build race

package p

const race = true
// +build !race

package p

const race = false

I think it would be better to have one boolean for that, and the most logical place for it seems to be either runtime/debug or runtime/race.

@ericlagergren

This comment has been minimized.

Copy link
Contributor

@ericlagergren ericlagergren commented Jan 9, 2020

I’ve done this in the past to skip tests that were only useful with the -race flag set.

@ianlancetaylor ianlancetaylor changed the title runtime/debug: add const Race proposal: runtime/debug: add const Race Jan 9, 2020
@gopherbot gopherbot added this to the Proposal milestone Jan 9, 2020
@gopherbot gopherbot added the Proposal label Jan 9, 2020
@josharian

This comment has been minimized.

Copy link
Contributor

@josharian josharian commented Jan 9, 2020

It seems to me a more natural place for this would be runtime/race.Enabled.

@josharian

This comment has been minimized.

Copy link
Contributor

@josharian josharian commented Jan 9, 2020

Note that the standard library has this already in internal/race.

@ainar-g

This comment has been minimized.

Copy link
Contributor Author

@ainar-g ainar-g commented Jan 9, 2020

@josharian, I can send a CL with something like:

package race

import "internal/race"

// Enabled tells whether the race detector was enabled when building.
const Enabled = enabled

const enabled = race.Enabled

If the proposal is accepted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.