Order of eval in struct keys

57 views
Skip to first unread message

roidel...@gmail.com

unread,
Apr 17, 2020, 11:55:24 AM4/17/20
to golang-nuts
Hi,

Reading https://golang.org/ref/spec#Order_of_evaluation does not explain if the order of evaluation in struct is defined.


Is that behavior guaranteed?

Thanks

Ian Lance Taylor

unread,
Apr 17, 2020, 12:27:26 PM4/17/20
to roidel...@gmail.com, golang-nuts
There is no guarantee about the order of evaluation within a composite
literal in general. However, there is a guarantee that all function
calls will be evaluated in left to right order in any expression,
including a composite literal. So while you didn't actually say what
you expect, I think that your example is guaranteed to behave the same
in any Go implementation.

Ian
Reply all
Reply to author
Forward
0 new messages