You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts
https://golang.org/pkg/reflect/#Value.Field says "Field returns the i'th field of the struct v.". Are there any guarantees as to what the ordering of the i'th field is? If not, does anyone know what the current behavior is, and whether it may change in the future? Is there a way to get the fields in declaration order?
I'm asking because a serialization library I'm using uses the above field order when serializing structs as arrays, and I encountered a case where it seems to diverge from declaration order. If this is something that may change in the future, the users of that library (and anything like it) would probably break...
-- Fred
Ian Lance Taylor
unread,
Jun 13, 2017, 3:33:00 PM6/13/17
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to aka...@keyba.se, golang-nuts
It's the order in which the fields appear in the struct declaration.
It's not going to change. If you find a case where it is *not* the
order in the declaration, please file a bug. Thanks.
Ian
aka...@keyba.se
unread,
Jun 13, 2017, 4:58:30 PM6/13/17
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts, aka...@keyba.se
On Tuesday, June 13, 2017 at 2:33:00 PM UTC-5, Ian Lance Taylor wrote:
It's the order in which the fields appear in the struct declaration.
It's not going to change. If you find a case where it is *not* the
order in the declaration, please file a bug. Thanks.
Ian
Thanks for the clarification. After some further digging, this turned out to be a bug in how the serialization library handles embedded structs.