Re: [go-nuts] reflect.Type.Field() order

2017-06-13 Thread akalin
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.

-- Fred

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] reflect.Type.Field() order

2017-06-13 Thread Ian Lance Taylor
On Tue, Jun 13, 2017 at 8:24 AM,   wrote:
>
> 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?
>
> Looking around online turned up
> https://stackoverflow.com/questions/32392311/reflect-type-field-order ,
> which didn't come to any conclusion.
>
> 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...

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

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] reflect.Type.Field() order

2017-06-13 Thread akalin
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?

Looking around online turned 
up https://stackoverflow.com/questions/32392311/reflect-type-field-order , 
which didn't come to any conclusion.

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

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.