Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
testing/quick: quick.Value should check if a struct field can be set before doing so #27017
What version of Go are you using (
changed the title
quick.Value should check if a struct field can be set before doing so
Aug 16, 2018
This limitation is explicitly documented in the
so this probably wasn't an oversight. It would be interesting to understand if this limitation was introduced for some "deep" reason, and if it is effectively safe to remove. Digging into the
I think it would be misleading for testing/quick to simply ignore unexported fields. That would produce the misleading impression that the struct was being tested when it fact it is not.
It would be nicer to return an error if possible rather than panic, but I don't think we should start ignoring unexported fields. testing/quick is not a general purpose tool, and to be honest it probably shouldn't be in the standard library. It's a specific tool for specific purposes, and for structs it requires all fields to be exported.
The more general version of testing/quick is fuzzing, and discussion about that is over at #19109.