learning golang again
Type size
https://github.com/ardanlabs/gotraining-studyguide/blob/master/go/language/struct.go
1 | type example struct { |
字节对齐系数 #pragma pack(n)
- 成员对齐
- 结构体对齐
对齐系数规则
- For a variable x of any type: unsafe.Alignof(x) is at least 1.
- For a variable x of struct type: unsafe.Alignof(x) is the largest of all the values unsafe.Alignof(x.f) for each field f of x, but at least 1.
- For a variable x of array type: unsafe.Alignof(x) is the same as the alignment of a variable of the array’s element type.
layout
- bool(0)
- int16(2)
- float32(4)
8 bytes
https://eddycjy.gitbook.io/golang/di-1-ke-za-tan/go-memory-align
//TODO list