When I do a Sizeof a struct, I always get 8, no matter how many fields
are in the struct.
type T struct { a, b, c, d int }
func main() {
fmt.Println(unsafe.Sizeof(T{}))
}
Structs are allocated in 8-byte blocks on 64-bit systems:
adg ~/test$ cat sizeof.go
package main
import "unsafe"
type A struct { a int }
type B struct { a, b int }
type C struct { a, b, c int }
type D struct { a, b, c, d int }
type E struct { a, b, c, d, e int }
func main() {
println(unsafe.Sizeof(A{}))
println(unsafe.Sizeof(B{}))
println(unsafe.Sizeof(C{}))
println(unsafe.Sizeof(D{}))
println(unsafe.Sizeof(E{}))
}
adg ~/test$ ./6.out
8
8
16
16
24
adg ~/test$ ./8.out
4
8
12
16
20
This also might explain what Don is seeing.
Andrew