testing/quick: quick.Value should check if a struct field can be set before doing so #27017
Labels
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
WaitingForInfo
Issue is not actionable because of missing required information, which needs to be provided.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?What did you do?
Using
quick.Value
to create a struct with randomly generated values, however a panic occurs if the function tries to set a field it cannot write to, such as an un-exported field. See https://play.golang.org/p/IlQgp7vxDk8 for an example.What did you expect to see?
I would expect un-exported fields to be ignored and a struct to be successfully generated.
What did you see instead?
reflect.Value.Set
is called on a field that cannot be set and a panic is triggered.The text was updated successfully, but these errors were encountered: