proposal: testing: panic if benchmark function tampers with b.N? #14479
Labels
Milestone
Comments
There are probably other places in the stdlib, as well as in 3rd party packages, where mutating a struct field/package level variable, intended only for reading, will create mess. That's why I think some |
On the surface, a vet check is plausible. On the other hand, if you're new enough to Go to consider setting |
These seems of extremely marginal utility, and once we go down this road we will spend more time being defensive than being productive. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
If the benchmark function changes b.N, the
testing
package will get very confused.As an example, this (contrived) function:
will lead to this:
I've seen this in the wild, for example:
https://groups.google.com/forum/#!topic/golang-nuts/DjKNjpSHi3M
The text was updated successfully, but these errors were encountered: