[0]byte in golang should not take any memory space. But these two structs have different sizes.
type bar2 struct {
A int
_ [0]byte
}
type bar3 struct {
_ [0]byte
A int
}
So why the position of [0]byte matters here?
By the way, I use unsafe.Sizeof() method to check the struct size. See the full example .