A common mistake is placing small fields around a large, alignment-sensitive field. Go inserts padding so each field starts at a suitable address, and the resulting struct can consume more memory than its visible fields suggest. section 12.4
Reordering removes padding
This layout places an int64 between two bytes and occupies 24 bytes: type Foo struct { b1 byte i int64 b2 byte } Putting the int64 first lets the two byte fields share the remaining space, reducing the struct to 16 bytes: type Foo struct { i int64 b1 byte b2 byte } Explicit padding can represent the first layout, but reordering is usually the simpler fix when field order is not part of an external contract.
The benefit is not only lower per-value memory use. A slice of the compact struct fits more relevant fields into each cache line, so a loop that sums Foo.i may need fewer cache lines.
