
A struct is a typed collection of fields, useful for grouping data into records. This allows all the data relating to one entity to be neatly encap...
For further actions, you may consider blocking this person and/or reporting abuse
🔥🔥🔥
thanks
Great way to explain this topic. congrats
Thanks
Didn't get why empty pad of 7 bytes, 7 bytes and 4 bytes respectively were added to make the sum of 8 bytes by complier? Why 8?
Because, the current version of the standard Go compiler, the alignment guarantees of other types may be either
4
or8
, depends on different build target architectures. This is also true forgccgo
.Thanks a lot of your detailed explanation. Helpful alot
Glad to know!!
Thanks for the write up! TIL, go compiler doesn't auto align the struct. I wonder if I should fit my struct to 128bit, hoping that the compiler will optimize some of r/w fields operation with SIMD instructions 🤔
Interesting article. A linter might be a good idea in this case. It could make writing memory optimized structs quite easy. It can be integrated in CI as well instead of having to always rely on code reviews etc...
Here's a great ready-made solution:github.com/t34-dev/go-field-alignment
Great write-up!. Thanks so much for sharing your findings so clearly :)
Thanks @motaman