reflect: when creating anonymous fields, StructOf should attempt to compute the field name #26035
Labels
FrozenDueToAge
NeedsDecision
Feedback is required from experts, contributors, and/or the community before a change can be made.
Milestone
Creating an anonymous field with
reflect.StructOf
panics if not explicitly given a name.A name must be provided when the embedded type is not defined or the name differs from the name of the defined type, to simulate embedding of an alias to a defined type. It is necessary to require an explicit name in these cases.
However, the common case, and hence user expectation, is that embedding a defined type creates a field with the same name as the defined type.
For any
T
representing a defined type, the following should be equivalent:and
Originally reported by @Merovius as part of #24781. I'm breaking it into a separate issue for easier tracking.
The text was updated successfully, but these errors were encountered: